* [GOLD] Add --secure-plt option for ppc32
@ 2017-01-08 7:49 Alan Modra
2017-01-09 17:10 ` Cary Coutant
0 siblings, 1 reply; 4+ messages in thread
From: Alan Modra @ 2017-01-08 7:49 UTC (permalink / raw)
To: binutils; +Cc: Cary Coutant
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [GOLD] Add --secure-plt option for ppc32
2017-01-08 7:49 [GOLD] Add --secure-plt option for ppc32 Alan Modra
@ 2017-01-09 17:10 ` Cary Coutant
2017-01-09 22:23 ` Alan Modra
0 siblings, 1 reply; 4+ messages in thread
From: Cary Coutant @ 2017-01-09 17:10 UTC (permalink / raw)
To: Alan Modra; +Cc: Binutils
> + DEFINE_bool(secure_plt, options::TWO_DASHES , '\0', true,
> + N_("(PowerPC only) Use new-style PLT. (default and forced)"),
> + NULL);
Gold's --help will now print "(default)" automatically for this
option, so it's redundant here. What do you mean by "forced"?
-cary
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [GOLD] Add --secure-plt option for ppc32
2017-01-09 17:10 ` Cary Coutant
@ 2017-01-09 22:23 ` Alan Modra
2017-01-09 22:26 ` Cary Coutant
0 siblings, 1 reply; 4+ messages in thread
From: Alan Modra @ 2017-01-09 22:23 UTC (permalink / raw)
To: Cary Coutant; +Cc: Binutils
On Mon, Jan 09, 2017 at 09:10:29AM -0800, Cary Coutant wrote:
> > + DEFINE_bool(secure_plt, options::TWO_DASHES , '\0', true,
> > + N_("(PowerPC only) Use new-style PLT. (default and forced)"),
> > + NULL);
>
> Gold's --help will now print "(default)" automatically for this
> option, so it's redundant here. What do you mean by "forced"?
Oops, didn't even look at the help output. By forced I meant that
there is no --no-secure-plt (or --bss-plt) but saying that isn't
necessary. Will remove it and the unnecessary "default".
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [GOLD] Add --secure-plt option for ppc32
2017-01-09 22:23 ` Alan Modra
@ 2017-01-09 22:26 ` Cary Coutant
0 siblings, 0 replies; 4+ messages in thread
From: Cary Coutant @ 2017-01-09 22:26 UTC (permalink / raw)
To: Alan Modra; +Cc: Binutils
>> > + DEFINE_bool(secure_plt, options::TWO_DASHES , '\0', true,
>> > + N_("(PowerPC only) Use new-style PLT. (default and forced)"),
>> > + NULL);
>>
>> Gold's --help will now print "(default)" automatically for this
>> option, so it's redundant here. What do you mean by "forced"?
>
> Oops, didn't even look at the help output. By forced I meant that
> there is no --no-secure-plt (or --bss-plt) but saying that isn't
> necessary. Will remove it and the unnecessary "default".
OK with that change.
-cary
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-09 22:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-08 7:49 [GOLD] Add --secure-plt option for ppc32 Alan Modra
2017-01-09 17:10 ` Cary Coutant
2017-01-09 22:23 ` Alan Modra
2017-01-09 22:26 ` Cary Coutant
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).