This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[GOLD] Add --secure-plt option for ppc32
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Cc: Cary Coutant <ccoutant at gmail dot com>
- Date: Sun, 8 Jan 2017 18:18:55 +1030
- Subject: [GOLD] Add --secure-plt option for ppc32
- Authentication-results: sourceware.org; auth=none
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 if you're
using gold.
The patch also make gold detect --bss-plt code and error out rather
than producing a binary that crashes.
OK?
* options.h: Add --secure-plt option.
* powerpc.cc (Target_powerpc::Scan::local): Detect and error
on -fPIC bss-plt code.
(Target_powerpc::Scan::global): Likewise.
diff --git a/gold/options.h b/gold/options.h
index d7ac6cd..905162b 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -1203,6 +1203,10 @@ 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. (default and forced)"),
+ 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 4b5026f..681fac7 100644
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -5969,6 +5969,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:
@@ -6470,6 +6494,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:
--
Alan Modra
Australia Development Lab, IBM