| ... | @@ -8100,11 +8100,15 @@ fn loadObject( | ... | @@ -8100,11 +8100,15 @@ fn loadObject( |
| 8100 | if (opts.node_fixed) ni: { | 8100 | if (opts.node_fixed) ni: { |
| 8101 | const shndx_ni = opts.shndx.node(elf); | 8101 | const shndx_ni = opts.shndx.node(elf); |
| 8102 | const after_oni: MappedFile.Node.Index.Optional = after: { | 8102 | const after_oni: MappedFile.Node.Index.Optional = after: { |
| 8103 | const last_ni = shndx_ni.last(&elf.mf).unwrap() orelse break :after .none; | 8103 | var node_it = shndx_ni.last(&elf.mf); |
| 8104 | break :after switch (last_ni.position(&elf.mf)) { | 8104 | while (node_it.unwrap()) |cur_ni| { |
| 8105 | .header => .wrap(last_ni), | 8105 | switch (cur_ni.position(&elf.mf)) { |
| 8106 | .footer, .floating => .none, | 8106 | .header => break :after .wrap(cur_ni), // last header |
| 8107 | }; | 8107 | .footer, .floating => node_it = cur_ni.prev(&elf.mf), |
| | 8108 | } |
| | 8109 | } else { |
| | 8110 | break :after .none; |
| | 8111 | } |
| 8108 | }; | 8112 | }; |
| 8109 | break :ni try shndx_ni.addHeaderChildAfter(gpa, &elf.mf, after_oni, add_node_opts); | 8113 | break :ni try shndx_ni.addHeaderChildAfter(gpa, &elf.mf, after_oni, add_node_opts); |
| 8110 | } else try opts.shndx.node(elf).addFloatingChild(gpa, &elf.mf, add_node_opts), | 8114 | } else try opts.shndx.node(elf).addFloatingChild(gpa, &elf.mf, add_node_opts), |