| author | |
| committer | |
| log | 5381bfd3480a560440915de68641bc0b55a33e74 |
| tree | 307ebb11a9dead20067664c4d5f52acc97a0fe7a |
| parent | 8e90b41ae044d976a710d608c95a7c801672d932 |
2 files changed, 9 insertions(+), 3 deletions(-)
src/link/Elf.zig+7-2| ... | ... | @@ -3433,9 +3433,14 @@ fn allocateLinkerDefinedSymbols(self: *Elf) void { |
| 3433 | 3433 | // _end |
| 3434 | 3434 | { |
| 3435 | 3435 | const end_symbol = self.symbol(self.end_index.?); |
| 3436 | end_symbol.value = 0; | |
| 3436 | 3437 | for (self.shdrs.items, 0..) |*shdr, shndx| { |
| 3437 | if (shdr.sh_flags & elf.SHF_ALLOC != 0) { | |
| 3438 | end_symbol.value = shdr.sh_addr + shdr.sh_size; | |
| 3438 | if (shdr.sh_flags & elf.SHF_ALLOC == 0) continue; | |
| 3439 | const phdr_index = self.phdr_to_shdr_table.get(@intCast(shndx)).?; | |
| 3440 | const phdr = self.phdrs.items[phdr_index]; | |
| 3441 | const value = phdr.p_vaddr + phdr.p_memsz; | |
| 3442 | if (end_symbol.value < value) { | |
| 3443 | end_symbol.value = value; | |
| 3439 | 3444 | end_symbol.output_section_index = @intCast(shndx); |
| 3440 | 3445 | } |
| 3441 | 3446 | } |
src/link/Elf/Symbol.zig+2-1| ... | ... | @@ -198,7 +198,8 @@ pub fn setOutputSym(symbol: Symbol, elf_file: *Elf, out: *elf.Elf64_Sym) void { |
| 198 | 198 | // } |
| 199 | 199 | if (st_shndx == elf.SHN_ABS) break :blk symbol.value; |
| 200 | 200 | const shdr = &elf_file.shdrs.items[st_shndx]; |
| 201 | if (shdr.sh_flags & elf.SHF_TLS != 0) break :blk symbol.value - elf_file.tlsAddress(); | |
| 201 | if (shdr.sh_flags & elf.SHF_TLS != 0 and file_ptr != .linker_defined) | |
| 202 | break :blk symbol.value - elf_file.tlsAddress(); | |
| 202 | 203 | break :blk symbol.value; |
| 203 | 204 | }; |
| 204 | 205 | out.* = .{ |