| ... | ... | @@ -308,9 +308,6 @@ const Node = union(enum) { |
| 308 | 308 | /// emitted a copy relocation. |
| 309 | 309 | /// |
| 310 | 310 | /// TODO it would be better to emit these into `.bss` or `.bss.rel.ro`, once we support those. |
| 311 | | /// |
| 312 | | /// TODO: currently, the `elf.copied_globals` entry may not be there---this case exists because |
| 313 | | /// `MappedFile` does not (yet?) support deleting nodes. See logic in `updateGlobalDynamic`. |
| 314 | 311 | copied_global: Symbol.Global.Index, |
| 315 | 312 | /// May contain relocations. |
| 316 | 313 | nav: NavMapIndex, |
| ... | ... | @@ -3335,10 +3332,8 @@ fn updateGlobalDynamic(elf: *Elf, orig_gsi: Symbol.Global.Index, force_apply_rel |
| 3335 | 3332 | } else { |
| 3336 | 3333 | if (elf.copied_globals.fetchSwapRemove(gsi)) |copied_global_kv| { |
| 3337 | 3334 | // We previously made a copy relocation, but now have deemed it unnecessary. |
| 3335 | try elf.deleteNode(copied_global_kv.value.node); |
| 3338 | 3336 | elf.shndx.rela_dyn.relaDeleteOne(elf, copied_global_kv.value.rela_index); |
| 3339 | | // TODO: once `MappedFile` has a way to delete a node (so it can re-use the |
| 3340 | | // space), we should delete `copied_global_kv.value.node`, which is an |
| 3341 | | // "orphaned" `copied_global` node. |
| 3342 | 3337 | apply_relocs = true; |
| 3343 | 3338 | } |
| 3344 | 3339 | } |
| ... | ... | @@ -3613,10 +3608,8 @@ fn deleteOwnedDynsym(elf: *Elf, gsi: Symbol.Global.Index) std.mem.Allocator.Erro |
| 3613 | 3608 | |
| 3614 | 3609 | var apply_relocs: bool = false; |
| 3615 | 3610 | if (elf.copied_globals.fetchSwapRemove(gsi)) |copied_global_kv| { |
| 3611 | try elf.deleteNode(copied_global_kv.value.node); |
| 3616 | 3612 | elf.shndx.rela_dyn.relaDeleteOne(elf, copied_global_kv.value.rela_index); |
| 3617 | | // TODO: once `MappedFile` has a way to delete a node (so it can re-use the |
| 3618 | | // space), we should delete `copied_global_kv.value.node`, which is an |
| 3619 | | // "orphaned" `copied_global` node. |
| 3620 | 3613 | apply_relocs = true; |
| 3621 | 3614 | } |
| 3622 | 3615 | if (elf.plt.getIndex(gsi)) |plt_index| { |
| ... | ... | @@ -11444,11 +11437,7 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void |
| 11444 | 11437 | }); |
| 11445 | 11438 | }, |
| 11446 | 11439 | .copied_global => |global_name| { |
| 11447 | | const copied_global = elf.copied_globals.getPtr(global_name) orelse { |
| 11448 | | // TODO: this node is orphaned, which is possible because `MappedFile` does not yet |
| 11449 | | // support deleting nodes. See logic in `updateGlobalDynamic`. |
| 11450 | | return; |
| 11451 | | }; |
| 11440 | const copied_global = elf.copied_globals.getPtr(global_name).?; |
| 11452 | 11441 | assert(copied_global.node == ni); |
| 11453 | 11442 | |
| 11454 | 11443 | const new_addr = elf.computeNodeVAddr(ni); |
| ... | ... | @@ -13008,11 +12997,9 @@ pub fn addNodeAssumeCapacity(elf: *Elf, ni: MappedFile.Node.Index, node: Node) M |
| 13008 | 12997 | return ni; |
| 13009 | 12998 | } |
| 13010 | 12999 | |
| 13011 | | fn deleteNode(elf: *Elf, node: *MappedFile.Node.Index.Optional) std.mem.Allocator.Error!void { |
| 13012 | | const ni = node.unwrap().?; |
| 13013 | | try ni.delete(elf.base.comp.gpa, &elf.mf); |
| 13014 | | elf.nodes.set(@backingInt(ni), .deleted); |
| 13015 | | node.* = .none; |
| 13000 | fn deleteNode(elf: *Elf, node: MappedFile.Node.Index) std.mem.Allocator.Error!void { |
| 13001 | try node.delete(elf.base.comp.gpa, &elf.mf); |
| 13002 | elf.nodes.set(@backingInt(node), .deleted); |
| 13016 | 13003 | } |
| 13017 | 13004 | |
| 13018 | 13005 | /// If `sym` has a PLT entry, returns the address of that entry (specifically, the address which a |