Mark Wielaard 16224b3
commit a95c4ad24cf83b2b0273fee73162bf476cebec8f
Mark Wielaard 16224b3
Author: Mark Wielaard <mjw@redhat.com>
Mark Wielaard 16224b3
Date:   Fri Jul 4 14:30:48 2014 +0200
Mark Wielaard 16224b3
Mark Wielaard 16224b3
    Add ppc64le ELFv2 abi support to backends and elflint.
Mark Wielaard 16224b3
    
Mark Wielaard 16224b3
    The big endian vs little endian changes are already handled by detecting
Mark Wielaard 16224b3
    the EI_DATA data encoding. And the function descriptors are already not
Mark Wielaard 16224b3
    used when we see there is no .opd section. This change adds new checks
Mark Wielaard 16224b3
    for st_other bits, new relocations and recognizes DT_PPC64_OPT.
Mark Wielaard 16224b3
    
Mark Wielaard 16224b3
    Signed-off-by: Menanteau Guy <menantea@linux.vnet.ibm.com>
Mark Wielaard 16224b3
    Signed-off-by: Mark Wielaard <mjw@redhat.com>
Mark Wielaard 16224b3
Mark Wielaard 16224b3
diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c
Mark Wielaard 16224b3
index e52231c..7ea2b23 100644
Mark Wielaard 16224b3
--- a/backends/ppc64_init.c
Mark Wielaard 16224b3
+++ b/backends/ppc64_init.c
Mark Wielaard 16224b3
@@ -61,6 +61,7 @@ ppc64_init (elf, machine, eh, ehlen)
Mark Wielaard 16224b3
   HOOK (eh, machine_flag_check);
Mark Wielaard 16224b3
   HOOK (eh, copy_reloc_p);
Mark Wielaard 16224b3
   HOOK (eh, check_special_symbol);
Mark Wielaard 16224b3
+  HOOK (eh, check_st_other_bits);
Mark Wielaard 16224b3
   HOOK (eh, bss_plt_p);
Mark Wielaard 16224b3
   HOOK (eh, return_value_location);
Mark Wielaard 16224b3
   HOOK (eh, register_info);
Mark Wielaard 16224b3
diff --git a/backends/ppc64_reloc.def b/backends/ppc64_reloc.def
Mark Wielaard 16224b3
index 6366f46..3a693cf 100644
Mark Wielaard 16224b3
--- a/backends/ppc64_reloc.def
Mark Wielaard 16224b3
+++ b/backends/ppc64_reloc.def
Mark Wielaard 16224b3
@@ -132,6 +132,21 @@ RELOC_TYPE (DTPREL16_HIGHER,	REL)
Mark Wielaard 16224b3
 RELOC_TYPE (DTPREL16_HIGHERA,	REL)
Mark Wielaard 16224b3
 RELOC_TYPE (DTPREL16_HIGHEST,	REL)
Mark Wielaard 16224b3
 RELOC_TYPE (DTPREL16_HIGHESTA,	REL)
Mark Wielaard 16224b3
+RELOC_TYPE (TLSGD,		REL)
Mark Wielaard 16224b3
+RELOC_TYPE (TLSLD,		REL)
Mark Wielaard 16224b3
+RELOC_TYPE (TOCSAVE,		REL)
Mark Wielaard 16224b3
+RELOC_TYPE (ADDR16_HIGH,	REL)
Mark Wielaard 16224b3
+RELOC_TYPE (ADDR16_HIGHA,	REL)
Mark Wielaard 16224b3
+RELOC_TYPE (TPREL16_HIGH,	REL)
Mark Wielaard 16224b3
+RELOC_TYPE (TPREL16_HIGHA,	REL)
Mark Wielaard 16224b3
+RELOC_TYPE (DTPREL16_HIGH,	REL)
Mark Wielaard 16224b3
+RELOC_TYPE (DTPREL16_HIGHA,	REL)
Mark Wielaard 16224b3
+RELOC_TYPE (JMP_IREL,		REL)
Mark Wielaard 16224b3
+RELOC_TYPE (IRELATIVE,		REL)
Mark Wielaard 16224b3
+RELOC_TYPE (REL16,		REL)
Mark Wielaard 16224b3
+RELOC_TYPE (REL16_LO,		REL)
Mark Wielaard 16224b3
+RELOC_TYPE (REL16_HI,		REL)
Mark Wielaard 16224b3
+RELOC_TYPE (REL16_HA,		REL)
Mark Wielaard 16224b3
 
Mark Wielaard 16224b3
 /* Notes from Alan Modra:
Mark Wielaard 16224b3
 
Mark Wielaard 16224b3
diff --git a/backends/ppc64_symbol.c b/backends/ppc64_symbol.c
Mark Wielaard 16224b3
index 212d414..5a020d8 100644
Mark Wielaard 16224b3
--- a/backends/ppc64_symbol.c
Mark Wielaard 16224b3
+++ b/backends/ppc64_symbol.c
Mark Wielaard 16224b3
@@ -72,6 +72,8 @@ ppc64_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)),
Mark Wielaard 16224b3
       return "PPC64_OPD";
Mark Wielaard 16224b3
     case DT_PPC64_OPDSZ:
Mark Wielaard 16224b3
       return "PPC64_OPDSZ";
Mark Wielaard 16224b3
+    case DT_PPC64_OPT:
Mark Wielaard 16224b3
+      return "PPC64_OPT";
Mark Wielaard 16224b3
     default:
Mark Wielaard 16224b3
       break;
Mark Wielaard 16224b3
     }
Mark Wielaard 16224b3
@@ -84,7 +86,8 @@ ppc64_dynamic_tag_check (int64_t tag)
Mark Wielaard 16224b3
 {
Mark Wielaard 16224b3
   return (tag == DT_PPC64_GLINK
Mark Wielaard 16224b3
 	  || tag == DT_PPC64_OPD
Mark Wielaard 16224b3
-	  || tag == DT_PPC64_OPDSZ);
Mark Wielaard 16224b3
+	  || tag == DT_PPC64_OPDSZ
Mark Wielaard 16224b3
+	  || tag == DT_PPC64_OPT);
Mark Wielaard 16224b3
 }
Mark Wielaard 16224b3
 
Mark Wielaard 16224b3
 
Mark Wielaard 16224b3
@@ -120,3 +123,9 @@ ppc64_machine_flag_check (GElf_Word flags)
Mark Wielaard 16224b3
 {
Mark Wielaard 16224b3
   return flags == 0 || flags == 1 || flags == 2;
Mark Wielaard 16224b3
 }
Mark Wielaard 16224b3
+
Mark Wielaard 16224b3
+bool
Mark Wielaard 16224b3
+ppc64_check_st_other_bits (unsigned char st_other)
Mark Wielaard 16224b3
+{
Mark Wielaard 16224b3
+  return (PPC64_LOCAL_ENTRY_OFFSET (st_other) != 0);
Mark Wielaard 16224b3
+}
Mark Wielaard 16224b3
diff --git a/src/elflint.c b/src/elflint.c
Mark Wielaard 16224b3
index 5568c65..d6a4774 100644
Mark Wielaard 16224b3
--- a/src/elflint.c
Mark Wielaard 16224b3
+++ b/src/elflint.c
Mark Wielaard 16224b3
@@ -799,7 +799,8 @@ section [%2d] '%s': symbol %zu: function in COMMON section is nonsense\n"),
Mark Wielaard 16224b3
 				  && strcmp (name, "__fini_array_end") != 0
Mark Wielaard 16224b3
 				  && strcmp (name, "__bss_start") != 0
Mark Wielaard 16224b3
 				  && strcmp (name, "__bss_start__") != 0
Mark Wielaard 16224b3
-				  && strcmp (name, "__TMC_END__") != 0))
Mark Wielaard 16224b3
+				  && strcmp (name, "__TMC_END__") != 0
Mark Wielaard 16224b3
+				  && strcmp (name, ".TOC.") != 0))
Mark Wielaard 16224b3
 			    ERROR (gettext ("\
Mark Wielaard 16224b3
 section [%2d] '%s': symbol %zu: st_value out of bounds\n"),
Mark Wielaard 16224b3
 				   idx, section_name (ebl, idx), cnt);