aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-05-18 12:52:01 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2012-05-18 12:52:01 -0400
commit8a3b947c40cb36100f316ac0d433f4ae554ee4cc (patch)
treee05a1aad6ae5235efb4195851080d85874175a9c /arch
parentc54a354c1835e7412a53458891b9ea05361b4e8a (diff)
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: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/tools/relocs.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index b49c2119295e..dce982d4bc31 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -570,10 +570,14 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
570 Elf32_Sym *sym; 570 Elf32_Sym *sym;
571 unsigned r_type; 571 unsigned r_type;
572 const char *symname; 572 const char *symname;
573 int shn_abs;
574
573 rel = &sec->reltab[j]; 575 rel = &sec->reltab[j];
574 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)]; 576 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
575 r_type = ELF32_R_TYPE(rel->r_info); 577 r_type = ELF32_R_TYPE(rel->r_info);
576 578
579 shn_abs = sym->st_shndx == SHN_ABS;
580
577 switch (r_type) { 581 switch (r_type) {
578 case R_386_NONE: 582 case R_386_NONE:
579 case R_386_PC32: 583 case R_386_PC32:
@@ -589,7 +593,7 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
589 symname = sym_name(sym_strtab, sym); 593 symname = sym_name(sym_strtab, sym);
590 if (!use_real_mode) 594 if (!use_real_mode)
591 goto bad; 595 goto bad;
592 if (sym->st_shndx == SHN_ABS) { 596 if (shn_abs) {
593 if (is_reloc(S_ABS, symname)) 597 if (is_reloc(S_ABS, symname))
594 break; 598 break;
595 else if (!is_reloc(S_SEG, symname)) 599 else if (!is_reloc(S_SEG, symname))
@@ -605,7 +609,7 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
605 609
606 case R_386_32: 610 case R_386_32:
607 symname = sym_name(sym_strtab, sym); 611 symname = sym_name(sym_strtab, sym);
608 if (sym->st_shndx == SHN_ABS) { 612 if (shn_abs) {
609 if (is_reloc(S_ABS, symname)) 613 if (is_reloc(S_ABS, symname))
610 break; 614 break;
611 else if (!is_reloc(S_REL, symname)) 615 else if (!is_reloc(S_REL, symname))
@@ -623,7 +627,8 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
623 break; 627 break;
624 bad: 628 bad:
625 symname = sym_name(sym_strtab, sym); 629 symname = sym_name(sym_strtab, sym);
626 die("Invalid %s relocation: %s\n", 630 die("Invalid %s %s relocation: %s\n",
631 shn_abs ? "absolute" : "relative",
627 rel_type(r_type), symname); 632 rel_type(r_type), symname);
628 } 633 }
629 } 634 }