(&self, name: &ModuleRelocTarget)
| 211 | } |
| 212 | |
| 213 | fn get_address(&self, name: &ModuleRelocTarget) -> *const u8 { |
| 214 | match name { |
| 215 | ModuleRelocTarget::User { .. } => { |
| 216 | let (name, linkage) = if ModuleDeclarations::is_function(name) { |
| 217 | let func_id = FuncId::from_name(name); |
| 218 | match &self.compiled_functions[func_id] { |
| 219 | Some(compiled) => return compiled.ptr(), |
| 220 | None => { |
| 221 | let decl = self.declarations.get_function_decl(func_id); |
| 222 | (&decl.name, decl.linkage) |
| 223 | } |
| 224 | } |
| 225 | } else { |
| 226 | let data_id = DataId::from_name(name); |
| 227 | match &self.compiled_data_objects[data_id] { |
| 228 | Some(compiled) => return compiled.ptr(), |
| 229 | None => { |
| 230 | let decl = self.declarations.get_data_decl(data_id); |
| 231 | (&decl.name, decl.linkage) |
| 232 | } |
| 233 | } |
| 234 | }; |
| 235 | let name = name |
| 236 | .as_ref() |
| 237 | .expect("anonymous symbol must be defined locally"); |
| 238 | if let Some(ptr) = self.lookup_symbol(name) { |
| 239 | ptr |
| 240 | } else if linkage == Linkage::Preemptible { |
| 241 | 0 as *const u8 |
| 242 | } else { |
| 243 | panic!("can't resolve symbol {name}"); |
| 244 | } |
| 245 | } |
| 246 | ModuleRelocTarget::LibCall(libcall) => { |
| 247 | let sym = (self.libcall_names)(*libcall); |
| 248 | self.lookup_symbol(&sym) |
| 249 | .unwrap_or_else(|| panic!("can't resolve libcall {sym}")) |
| 250 | } |
| 251 | ModuleRelocTarget::FunctionOffset(func_id, offset) => { |
| 252 | match &self.compiled_functions[*func_id] { |
| 253 | Some(compiled) => return compiled.ptr().wrapping_add(*offset as usize), |
| 254 | None => todo!(), |
| 255 | } |
| 256 | } |
| 257 | name => panic!("invalid name {name:?}"), |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | /// Returns the address of a finalized function. |
| 262 | /// |
no test coverage detected