This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb/binutils-2_28-branch] [GOLD] Add --secure-plt option for ppc32


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6cbdd7903274381ad2faf43fe26e31554baed087

commit 6cbdd7903274381ad2faf43fe26e31554baed087
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Jan 10 10:24:09 2017 +1030

    [GOLD] Add --secure-plt option for ppc32
    
    Added just to accept, and ignore.  gcc since 2015-10-21, when
    configured with --enable-secureplt passes this option to the linker.
    As powerpc gold cannot link --bss-plt code successfully, gold needs to
    accept the option or the gcc specs file needs to be changed.
    
    The patch also make gold detect --bss-plt code and error out rather
    than producing a binary that crashes.
    
    	* options.h: Add --secure-plt option.
    	* powerpc.cc (Target_powerpc::Scan::local): Detect and error
    	on -fPIC -mbss-plt code.
    	(Target_powerpc::Scan::global): Likewise.

Diff:
---
 gold/ChangeLog  |  7 +++++++
 gold/options.h  |  3 +++
 gold/powerpc.cc | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 1159f9c..bf834f8 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,10 @@
+2017-01-10  Alan Modra  <amodra@gmail.com>
+
+	* options.h: Add --secure-plt option.
+	* powerpc.cc (Target_powerpc::Scan::local): Detect and error
+	on -fPIC -mbss-plt code.
+	(Target_powerpc::Scan::global): Likewise.
+
 2017-01-09  Alan Modra  <amodra@gmail.com>
 
 	* powerpc.cc (Target_powerpc::make_plt_section): Point sh_info of
diff --git a/gold/options.h b/gold/options.h
index d7ac6cd..a8b1d46 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -1203,6 +1203,9 @@ class General_options
   DEFINE_special(section_start, options::TWO_DASHES, '\0',
 		 N_("Set address of section"), N_("SECTION=ADDRESS"));
 
+  DEFINE_bool(secure_plt, options::TWO_DASHES , '\0', true,
+	      N_("(PowerPC only) Use new-style PLT"), NULL);
+
   DEFINE_optional_string(sort_common, options::TWO_DASHES, '\0', NULL,
 			 N_("Sort common symbols by alignment"),
 			 N_("[={ascending,descending}]"));
diff --git a/gold/powerpc.cc b/gold/powerpc.cc
index 6d6d0dd..b91fb4b 100644
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -5972,6 +5972,30 @@ Target_powerpc<size, big_endian>::Scan::local(
       break;
     }
 
+  if (size == 32)
+    {
+      switch (r_type)
+	{
+	case elfcpp::R_POWERPC_REL32:
+	  if (ppc_object->got2_shndx() != 0
+	      && parameters->options().output_is_position_independent())
+	    {
+	      unsigned int shndx = lsym.get_st_shndx();
+	      unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
+	      bool is_ordinary;
+	      shndx = ppc_object->adjust_sym_shndx(r_sym, shndx, &is_ordinary);
+	      if (is_ordinary && shndx == ppc_object->got2_shndx()
+		  && (ppc_object->section_flags(data_shndx)
+		      & elfcpp::SHF_EXECINSTR) != 0)
+		gold_error(_("%s: unsupported -mbss-plt code"),
+			   ppc_object->name().c_str());
+	    }
+	  break;
+	default:
+	  break;
+	}
+    }
+
   switch (r_type)
     {
     case elfcpp::R_POWERPC_GOT_TLSLD16:
@@ -6473,6 +6497,20 @@ Target_powerpc<size, big_endian>::Scan::global(
       break;
     }
 
+  if (size == 32)
+    {
+      switch (r_type)
+	{
+	case elfcpp::R_PPC_LOCAL24PC:
+	  if (strcmp(gsym->name(), "_GLOBAL_OFFSET_TABLE_") == 0)
+	    gold_error(_("%s: unsupported -mbss-plt code"),
+		       ppc_object->name().c_str());
+	  break;
+	default:
+	  break;
+	}
+    }
+
   switch (r_type)
     {
     case elfcpp::R_POWERPC_GOT_TLSLD16:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]