mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-02-05 16:51:27 +08:00
output: elf -- Use ElfX_Relx in elf_build_reltab
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
a95a8e6d7f
commit
b074501887
@ -2053,9 +2053,16 @@ static struct SAA *elf_build_symtab(int32_t *len, int32_t *local)
|
|||||||
static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r)
|
static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r)
|
||||||
{
|
{
|
||||||
struct SAA *s;
|
struct SAA *s;
|
||||||
uint8_t *p, entry[24];
|
|
||||||
int32_t global_offset;
|
int32_t global_offset;
|
||||||
|
|
||||||
|
size_t usize = is_elf64() ? sizeof(Elf64_Rela) :
|
||||||
|
(is_elfx32() ? sizeof(Elf32_Rela) : sizeof(Elf32_Rel));
|
||||||
|
union {
|
||||||
|
Elf32_Rel rel32;
|
||||||
|
Elf32_Rela rela32;
|
||||||
|
Elf64_Rela rela64;
|
||||||
|
} u;
|
||||||
|
|
||||||
if (!r)
|
if (!r)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -2076,11 +2083,10 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r)
|
|||||||
if (sym >= GLOBAL_TEMP_BASE)
|
if (sym >= GLOBAL_TEMP_BASE)
|
||||||
sym += global_offset;
|
sym += global_offset;
|
||||||
|
|
||||||
p = entry;
|
u.rel32.r_offset = long_le(r->address);
|
||||||
WRITELONG(p, r->address);
|
u.rel32.r_info = long_le(ELF32_R_INFO(sym, r->type));
|
||||||
WRITELONG(p, (sym << 8) + r->type);
|
saa_wbytes(s, &u, usize);
|
||||||
saa_wbytes(s, entry, 8L);
|
*len += usize;
|
||||||
*len += 8;
|
|
||||||
|
|
||||||
r = r->next;
|
r = r->next;
|
||||||
}
|
}
|
||||||
@ -2091,12 +2097,11 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r)
|
|||||||
if (sym >= GLOBAL_TEMP_BASE)
|
if (sym >= GLOBAL_TEMP_BASE)
|
||||||
sym += global_offset;
|
sym += global_offset;
|
||||||
|
|
||||||
p = entry;
|
u.rela32.r_offset = long_le(r->address);
|
||||||
WRITELONG(p, r->address);
|
u.rela32.r_info = long_le(ELF32_R_INFO(sym, r->type));
|
||||||
WRITELONG(p, (sym << 8) + r->type);
|
u.rela32.r_addend = long_le(r->offset);
|
||||||
WRITELONG(p, r->offset);
|
saa_wbytes(s, &u, usize);
|
||||||
saa_wbytes(s, entry, 12L);
|
*len += usize;
|
||||||
*len += 12;
|
|
||||||
|
|
||||||
r = r->next;
|
r = r->next;
|
||||||
}
|
}
|
||||||
@ -2108,13 +2113,11 @@ static struct SAA *elf_build_reltab(uint64_t *len, struct elf_reloc *r)
|
|||||||
if (sym >= GLOBAL_TEMP_BASE)
|
if (sym >= GLOBAL_TEMP_BASE)
|
||||||
sym += global_offset;
|
sym += global_offset;
|
||||||
|
|
||||||
p = entry;
|
u.rela64.r_offset = dlong_le(r->address);
|
||||||
WRITEDLONG(p, r->address);
|
u.rela64.r_info = dlong_le(ELF64_R_INFO(sym, r->type));
|
||||||
WRITELONG(p, r->type);
|
u.rela64.r_addend = dlong_le(r->offset);
|
||||||
WRITELONG(p, sym);
|
saa_wbytes(s, &u, usize);
|
||||||
WRITEDLONG(p, r->offset);
|
*len += usize;
|
||||||
saa_wbytes(s, entry, 24L);
|
|
||||||
*len += 24;
|
|
||||||
|
|
||||||
r = r->next;
|
r = r->next;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user