mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
elf: fix setting st_value of _end synthetic symbol
This commit is contained in:
parent
8e90b41ae0
commit
5381bfd348
@ -3433,9 +3433,14 @@ fn allocateLinkerDefinedSymbols(self: *Elf) void {
|
||||
// _end
|
||||
{
|
||||
const end_symbol = self.symbol(self.end_index.?);
|
||||
end_symbol.value = 0;
|
||||
for (self.shdrs.items, 0..) |*shdr, shndx| {
|
||||
if (shdr.sh_flags & elf.SHF_ALLOC != 0) {
|
||||
end_symbol.value = shdr.sh_addr + shdr.sh_size;
|
||||
if (shdr.sh_flags & elf.SHF_ALLOC == 0) continue;
|
||||
const phdr_index = self.phdr_to_shdr_table.get(@intCast(shndx)).?;
|
||||
const phdr = self.phdrs.items[phdr_index];
|
||||
const value = phdr.p_vaddr + phdr.p_memsz;
|
||||
if (end_symbol.value < value) {
|
||||
end_symbol.value = value;
|
||||
end_symbol.output_section_index = @intCast(shndx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,7 +198,8 @@ pub fn setOutputSym(symbol: Symbol, elf_file: *Elf, out: *elf.Elf64_Sym) void {
|
||||
// }
|
||||
if (st_shndx == elf.SHN_ABS) break :blk symbol.value;
|
||||
const shdr = &elf_file.shdrs.items[st_shndx];
|
||||
if (shdr.sh_flags & elf.SHF_TLS != 0) break :blk symbol.value - elf_file.tlsAddress();
|
||||
if (shdr.sh_flags & elf.SHF_TLS != 0 and file_ptr != .linker_defined)
|
||||
break :blk symbol.value - elf_file.tlsAddress();
|
||||
break :blk symbol.value;
|
||||
};
|
||||
out.* = .{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user