Commit 8a3b947c authored by H. Peter Anvin's avatar H. Peter Anvin

x86, relocs: When printing an error, say relative or absolute

When the relocs tool throws an error, let the error message say if it
is an absolute or relative symbol.  This should make it a lot more
clear what action the programmer needs to take.
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
parent c54a354c
...@@ -570,10 +570,14 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym), ...@@ -570,10 +570,14 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
Elf32_Sym *sym; Elf32_Sym *sym;
unsigned r_type; unsigned r_type;
const char *symname; const char *symname;
int shn_abs;
rel = &sec->reltab[j]; rel = &sec->reltab[j];
sym = &sh_symtab[ELF32_R_SYM(rel->r_info)]; sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
r_type = ELF32_R_TYPE(rel->r_info); r_type = ELF32_R_TYPE(rel->r_info);
shn_abs = sym->st_shndx == SHN_ABS;
switch (r_type) { switch (r_type) {
case R_386_NONE: case R_386_NONE:
case R_386_PC32: case R_386_PC32:
...@@ -589,7 +593,7 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym), ...@@ -589,7 +593,7 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
symname = sym_name(sym_strtab, sym); symname = sym_name(sym_strtab, sym);
if (!use_real_mode) if (!use_real_mode)
goto bad; goto bad;
if (sym->st_shndx == SHN_ABS) { if (shn_abs) {
if (is_reloc(S_ABS, symname)) if (is_reloc(S_ABS, symname))
break; break;
else if (!is_reloc(S_SEG, symname)) else if (!is_reloc(S_SEG, symname))
...@@ -605,7 +609,7 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym), ...@@ -605,7 +609,7 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
case R_386_32: case R_386_32:
symname = sym_name(sym_strtab, sym); symname = sym_name(sym_strtab, sym);
if (sym->st_shndx == SHN_ABS) { if (shn_abs) {
if (is_reloc(S_ABS, symname)) if (is_reloc(S_ABS, symname))
break; break;
else if (!is_reloc(S_REL, symname)) else if (!is_reloc(S_REL, symname))
...@@ -623,7 +627,8 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym), ...@@ -623,7 +627,8 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
break; break;
bad: bad:
symname = sym_name(sym_strtab, sym); symname = sym_name(sym_strtab, sym);
die("Invalid %s relocation: %s\n", die("Invalid %s %s relocation: %s\n",
shn_abs ? "absolute" : "relative",
rel_type(r_type), symname); rel_type(r_type), symname);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment