| ... | ... | @@ -3574,6 +3574,7 @@ fn initHeaders( |
| 3574 | 3574 | interp: u32, |
| 3575 | 3575 | rodata: u32, |
| 3576 | 3576 | text: u32, |
| 3577 | /// HACKHACK: must be assigned after all other loadable segments so that the data segment always has the greatest vaddr on SPARC |
| 3577 | 3578 | data: u32, |
| 3578 | 3579 | /// On most targets this is `undefined`, but on machines where JUMP_SLOT relocations write |
| 3579 | 3580 | /// directly to the PLT, we place the PLT in its own segment in order to avoid making the |
| ... | ... | @@ -3606,14 +3607,14 @@ fn initHeaders( |
| 3606 | 3607 | defer phnum += 1; |
| 3607 | 3608 | break :phndx phnum; |
| 3608 | 3609 | }, |
| 3609 | | .data = phndx: { |
| 3610 | | defer phnum += 1; |
| 3611 | | break :phndx phnum; |
| 3612 | | }, |
| 3613 | 3610 | .plt = if (plt.got_plt == null) phndx: { |
| 3614 | 3611 | defer phnum += 1; |
| 3615 | 3612 | break :phndx phnum; |
| 3616 | 3613 | } else undefined, |
| 3614 | .data = phndx: { |
| 3615 | defer phnum += 1; |
| 3616 | break :phndx phnum; |
| 3617 | }, |
| 3617 | 3618 | .tls = if (comp.config.any_non_single_threaded) phndx: { |
| 3618 | 3619 | defer phnum += 1; |
| 3619 | 3620 | break :phndx phnum; |
| ... | ... | @@ -8357,6 +8358,19 @@ fn allocateSegmentLoadAddress(elf: *Elf, orig_phndx: u32) std.mem.Allocator.Erro |
| 8357 | 8358 | break; // hooray, we fit here! |
| 8358 | 8359 | } |
| 8359 | 8360 | |
| 8361 | if (elf.phdrs.items[next_phndx] == elf.ni.data.toOptional()) { |
| 8362 | // HACKHACK: make sparc happy by keeping the data segment at the end |
| 8363 | // so, use the current candidate `vaddr` and just move the data segment's vaddr out of the way |
| 8364 | const next_ni = elf.phdrs.items[next_phndx].unwrap().?; |
| 8365 | const next_align = page_align.max(next_ni.alignment(&elf.mf)); |
| 8366 | const next_offset = elf.targetLoad(&next_ph.offset); |
| 8367 | const next_new_vaddr = next_align.forward(vaddr + target_size) + next_offset % next_align.toByteUnits(); |
| 8368 | elf.targetStore(&next_ph.vaddr, @intCast(next_new_vaddr)); |
| 8369 | elf.targetStore(&next_ph.paddr, @intCast(next_new_vaddr)); |
| 8370 | try next_ni.childrenMoved(elf.base.comp.gpa, &elf.mf); |
| 8371 | break; |
| 8372 | } |
| 8373 | |
| 8360 | 8374 | // We don't fit here, so shift ourselves forward (i.e. swap with `next_phndx`). But |
| 8361 | 8375 | // first we need to adjust `vaddr` to come after it. |
| 8362 | 8376 | const next_size = elf.targetLoad(&next_ph.memsz); |