This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PPC32 Secure-PLT Stub Symbols
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Ray Chen <rchen at cs dot umd dot edu>, binutils at sourceware dot org
- Date: Sat, 3 Oct 2009 00:47:28 +0930
- Subject: Re: PPC32 Secure-PLT Stub Symbols
- References: <11b9e99b0909301004h6b341d4crb8449e63648ab95e@mail.gmail.com> <20090930225416.GB18973@bubble.grove.modra.org>
On Thu, Oct 01, 2009 at 08:24:16AM +0930, Alan Modra wrote:
> On Wed, Sep 30, 2009 at 01:04:21PM -0400, Ray Chen wrote:
> > So is there a reason it wasn't implemented? I apologize if I have
> > overlooked something that obviates this question. I've been trying to
> > find a way around this for a while now.
>
> Invoke ld with --emit-stub-syms when building your -fPIC binary.
This patch turns on --emit-stubs-syms by default for PowerPC64, and
for PowerPC when --shared. I've been meaning to do this for a while
since you can't generate synthetic symbols on the plt call stubs
without doing quite a lot of analysis.
ld/
* emultempl/ppc32elf.em (emit_stub_syms): Init to -1.
(ppc_after_open): Set emit_stubs_syms by default when shared.
(OPTION_NO_STUBSYMS): Define.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS,
PARSE_AND_LIST_ARGS_CASES): Handle --no-emit-stub-syms.
* emultempl/ppc64elf.em (emit_stub_syms): Init to -1.
(gld${EMULATION_NAME}_finish): Set emit_stubs_syms by default.
(OPTION_NO_STUBSYMS): Define.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS,
PARSE_AND_LIST_ARGS_CASES): Handle --no-emit-stub-syms.
ld/testsuite/
* ld-powerpc/tlsexe.d: Update.
* ld-powerpc/tlsexe.r: Update.
* ld-powerpc/tlsexetoc.d: Update.
* ld-powerpc/tlsexetoc.r: Update.
* ld-powerpc/tlsso.d: Update.
* ld-powerpc/tlsso.r: Update.
* ld-powerpc/tlstocso.d: Update.
* ld-powerpc/tlstocso.r: Update.
Index: ld/emultempl/ppc32elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc32elf.em,v
retrieving revision 1.22
diff -u -p -r1.22 ppc32elf.em
--- ld/emultempl/ppc32elf.em 21 Sep 2009 11:51:02 -0000 1.22
+++ ld/emultempl/ppc32elf.em 2 Oct 2009 08:15:48 -0000
@@ -36,7 +36,7 @@ static int notlsopt = 0;
static int no_tls_get_addr_opt = 0;
/* Whether to emit symbols for stubs. */
-static int emit_stub_syms = 0;
+static int emit_stub_syms = -1;
/* Chooses the correct place for .plt and .got. */
static enum ppc_elf_plt_type plt_style = PLT_UNSET;
@@ -55,7 +55,8 @@ ppc_after_open (void)
lang_output_section_statement_type *plt_os[2];
lang_output_section_statement_type *got_os[2];
- emit_stub_syms |= link_info.emitrelocations;
+ if (emit_stub_syms < 0)
+ emit_stub_syms = link_info.emitrelocations || link_info.shared;
new_plt = ppc_elf_select_plt_layout (link_info.output_bfd, &link_info,
plt_style, emit_stub_syms);
if (new_plt < 0)
@@ -182,10 +183,12 @@ PARSE_AND_LIST_PROLOGUE='
#define OPTION_OLD_PLT (OPTION_NEW_PLT + 1)
#define OPTION_OLD_GOT (OPTION_OLD_PLT + 1)
#define OPTION_STUBSYMS (OPTION_OLD_GOT + 1)
+#define OPTION_NO_STUBSYMS (OPTION_STUBSYMS + 1)
'
PARSE_AND_LIST_LONGOPTS='
{ "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
+ { "no-emit-stub-syms", no_argument, NULL, OPTION_NO_STUBSYMS },
{ "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
{ "no-tls-get-addr-optimize", no_argument, NULL, OPTION_NO_TLS_GET_ADDR_OPT },
{ "secure-plt", no_argument, NULL, OPTION_NEW_PLT },
@@ -196,6 +199,7 @@ PARSE_AND_LIST_LONGOPTS='
PARSE_AND_LIST_OPTIONS='
fprintf (file, _("\
--emit-stub-syms Label linker stubs with a symbol.\n\
+ --no-emit-stub-syms Don'\''t label linker stubs with a symbol.\n\
--no-tls-optimize Don'\''t try to optimize TLS accesses.\n\
--no-tls-get-addr-optimize Don'\''t use a special __tls_get_addr call.\n\
--secure-plt Use new-style PLT if possible.\n\
@@ -209,6 +213,10 @@ PARSE_AND_LIST_ARGS_CASES='
emit_stub_syms = 1;
break;
+ case OPTION_NO_STUBSYMS:
+ emit_stub_syms = 0;
+ break;
+
case OPTION_NO_TLS_OPT:
notlsopt = 1;
break;
Index: ld/emultempl/ppc64elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc64elf.em,v
retrieving revision 1.64
diff -u -p -r1.64 ppc64elf.em
--- ld/emultempl/ppc64elf.em 21 Sep 2009 11:51:02 -0000 1.64
+++ ld/emultempl/ppc64elf.em 2 Oct 2009 14:50:33 -0000
@@ -59,7 +59,7 @@ static int no_toc_opt = 0;
static int no_multi_toc = 0;
/* Whether to emit symbols for stubs. */
-static int emit_stub_syms = 0;
+static int emit_stub_syms = -1;
static asection *toc_section = 0;
@@ -378,7 +378,8 @@ gld${EMULATION_NAME}_finish (void)
char *msg = NULL;
char *line, *endline;
- emit_stub_syms |= link_info.emitrelocations;
+ if (emit_stub_syms < 0)
+ emit_stub_syms = 1;
if (!ppc64_elf_build_stubs (emit_stub_syms, &link_info,
config.stats ? &msg : NULL))
einfo ("%X%P: can not build stubs: %E\n");
@@ -487,7 +488,8 @@ fi
PARSE_AND_LIST_PROLOGUE='
#define OPTION_STUBGROUP_SIZE 301
#define OPTION_STUBSYMS (OPTION_STUBGROUP_SIZE + 1)
-#define OPTION_DOTSYMS (OPTION_STUBSYMS + 1)
+#define OPTION_NO_STUBSYMS (OPTION_STUBSYMS + 1)
+#define OPTION_DOTSYMS (OPTION_NO_STUBSYMS + 1)
#define OPTION_NO_DOTSYMS (OPTION_DOTSYMS + 1)
#define OPTION_NO_TLS_OPT (OPTION_NO_DOTSYMS + 1)
#define OPTION_NO_TLS_GET_ADDR_OPT (OPTION_NO_TLS_OPT + 1)
@@ -500,6 +502,7 @@ PARSE_AND_LIST_PROLOGUE='
PARSE_AND_LIST_LONGOPTS='
{ "stub-group-size", required_argument, NULL, OPTION_STUBGROUP_SIZE },
{ "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
+ { "no-emit-stub-syms", no_argument, NULL, OPTION_NO_STUBSYMS },
{ "dotsyms", no_argument, NULL, OPTION_DOTSYMS },
{ "no-dotsyms", no_argument, NULL, OPTION_NO_DOTSYMS },
{ "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
@@ -525,6 +528,9 @@ PARSE_AND_LIST_OPTIONS='
--emit-stub-syms Label linker stubs with a symbol.\n"
));
fprintf (file, _("\
+ --no-emit-stub-syms Don'\''t label linker stubs with a symbol.\n"
+ ));
+ fprintf (file, _("\
--dotsyms For every version pattern \"foo\" in a version\n\
script, add \".foo\" so that function code\n\
symbols are treated the same as function\n\
@@ -568,6 +574,10 @@ PARSE_AND_LIST_ARGS_CASES='
emit_stub_syms = 1;
break;
+ case OPTION_NO_STUBSYMS:
+ emit_stub_syms = 0;
+ break;
+
case OPTION_DOTSYMS:
dotsyms = 1;
break;
Index: ld/testsuite/ld-powerpc/tlsexe.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsexe.d,v
retrieving revision 1.8
diff -u -p -r1.8 tlsexe.d
--- ld/testsuite/ld-powerpc/tlsexe.d 21 Sep 2009 11:51:02 -0000 1.8
+++ ld/testsuite/ld-powerpc/tlsexe.d 2 Oct 2009 07:05:32 -0000
@@ -8,7 +8,7 @@
Disassembly of section \.text:
-.* <_start-0x4c>:
+.* <00000010\.plt_call\.__tls_get_addr(|_opt)\+0>:
.* e9 63 00 00 ld r11,0\(r3\)
.* e9 83 00 08 ld r12,8\(r3\)
.* 7c 60 1b 78 mr r0,r3
@@ -71,6 +71,7 @@ Disassembly of section \.text:
.* 60 00 00 00 nop
.* 00 00 00 00 .*
.* 00 01 02 00 .*
+.* <__glink_PLTresolve>:
.* 7d 88 02 a6 mflr r12
.* 42 9f 00 05 bcl- 20,4\*cr7\+so,.*
.* 7d 68 02 a6 mflr r11
Index: ld/testsuite/ld-powerpc/tlsexe.r
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsexe.r,v
retrieving revision 1.24
diff -u -p -r1.24 tlsexe.r
--- ld/testsuite/ld-powerpc/tlsexe.r 24 Sep 2009 15:56:51 -0000 1.24
+++ ld/testsuite/ld-powerpc/tlsexe.r 2 Oct 2009 07:05:32 -0000
@@ -96,7 +96,9 @@ Symbol table '\.symtab' contains [0-9]+
.* TLS +LOCAL +DEFAULT +8 le4
.* TLS +LOCAL +DEFAULT +8 le5
.* OBJECT +LOCAL +DEFAULT +10 _DYNAMIC
-.* (FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt)
+.* (NOTYPE +LOCAL +DEFAULT +7 00000010\.plt_call\.__tls_get_addr(|_opt)\+0|(FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt))
+.* (NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve|NOTYPE +LOCAL +DEFAULT +7 00000010\.plt_call\.__tls_get_addr(|_opt)\+0)
+.* ((FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt)|NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve)
.* GLOBAL +DEFAULT +UND gd
.* GLOBAL +DEFAULT +9 le0
.* GLOBAL +DEFAULT +9 ld0
Index: ld/testsuite/ld-powerpc/tlsexetoc.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsexetoc.d,v
retrieving revision 1.9
diff -u -p -r1.9 tlsexetoc.d
--- ld/testsuite/ld-powerpc/tlsexetoc.d 21 Sep 2009 11:51:02 -0000 1.9
+++ ld/testsuite/ld-powerpc/tlsexetoc.d 2 Oct 2009 07:05:32 -0000
@@ -8,7 +8,7 @@
Disassembly of section \.text:
-.* <_start-0x4c>:
+.* <00000010\.plt_call\.__tls_get_addr(|_opt)\+0>:
.* e9 63 00 00 ld r11,0\(r3\)
.* e9 83 00 08 ld r12,8\(r3\)
.* 7c 60 1b 78 mr r0,r3
@@ -55,6 +55,7 @@ Disassembly of section \.text:
.* 60 00 00 00 nop
.* 00 00 00 00 .*
.* 00 01 02 28 .*
+.* <__glink_PLTresolve>:
.* 7d 88 02 a6 mflr r12
.* 42 9f 00 05 bcl- 20,4\*cr7\+so,.*
.* 7d 68 02 a6 mflr r11
Index: ld/testsuite/ld-powerpc/tlsexetoc.r
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsexetoc.r,v
retrieving revision 1.25
diff -u -p -r1.25 tlsexetoc.r
--- ld/testsuite/ld-powerpc/tlsexetoc.r 24 Sep 2009 15:56:51 -0000 1.25
+++ ld/testsuite/ld-powerpc/tlsexetoc.r 2 Oct 2009 07:05:32 -0000
@@ -96,7 +96,9 @@ Symbol table '\.symtab' contains [0-9]+
.* TLS +LOCAL +DEFAULT +8 le5
.* NOTYPE +LOCAL +DEFAULT +12 \.Lie0
.* OBJECT +LOCAL +DEFAULT +10 _DYNAMIC
-.* (FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt)
+.* (NOTYPE +LOCAL +DEFAULT +7 00000010\.plt_call\.__tls_get_addr(|_opt)\+0|(FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt))
+.* (NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve|NOTYPE +LOCAL +DEFAULT +7 00000010\.plt_call\.__tls_get_addr(|_opt)\+0)
+.* ((FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt)|NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve)
.* TLS +GLOBAL +DEFAULT +UND gd
.* TLS +GLOBAL +DEFAULT +9 le0
.* TLS +GLOBAL +DEFAULT +9 ld0
Index: ld/testsuite/ld-powerpc/tlsso.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsso.d,v
retrieving revision 1.8
diff -u -p -r1.8 tlsso.d
--- ld/testsuite/ld-powerpc/tlsso.d 18 Sep 2009 03:30:34 -0000 1.8
+++ ld/testsuite/ld-powerpc/tlsso.d 2 Oct 2009 07:05:32 -0000
@@ -8,7 +8,7 @@
Disassembly of section \.text:
-.*:
+.* <00000010\.plt_call\.__tls_get_addr(|_opt)\+0>:
.* f8 41 00 28 std r2,40\(r1\)
.* e9 62 80 78 ld r11,-32648\(r2\)
.* 7d 69 03 a6 mtctr r11
@@ -57,6 +57,7 @@ Disassembly of section \.text:
.* a9 49 00 00 lha r10,0\(r9\)
.* 00 00 00 00 .*
.* 00 01 02 20 .*
+.* <__glink_PLTresolve>:
.* 7d 88 02 a6 mflr r12
.* 42 9f 00 05 bcl- 20,4\*cr7\+so,.*
.* 7d 68 02 a6 mflr r11
Index: ld/testsuite/ld-powerpc/tlsso.r
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsso.r,v
retrieving revision 1.25
diff -u -p -r1.25 tlsso.r
--- ld/testsuite/ld-powerpc/tlsso.r 24 Sep 2009 15:56:51 -0000 1.25
+++ ld/testsuite/ld-powerpc/tlsso.r 2 Oct 2009 07:05:32 -0000
@@ -110,6 +110,8 @@ Symbol table '\.symtab' contains [0-9]+
.* TLS +LOCAL +DEFAULT +7 le4
.* TLS +LOCAL +DEFAULT +7 le5
.* OBJECT +LOCAL +DEFAULT +ABS _DYNAMIC
+.* NOTYPE +LOCAL +DEFAULT +6 00000010\.plt_call\.__tls_get_addr\+0
+.* NOTYPE +LOCAL +DEFAULT +6 __glink_PLTresolve
.* NOTYPE +LOCAL +DEFAULT +UND \.__tls_get_addr
.* TLS +GLOBAL +DEFAULT +UND gd
.* TLS +GLOBAL +DEFAULT +8 le0
Index: ld/testsuite/ld-powerpc/tlstocso.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlstocso.d,v
retrieving revision 1.7
diff -u -p -r1.7 tlstocso.d
--- ld/testsuite/ld-powerpc/tlstocso.d 18 Sep 2009 03:30:34 -0000 1.7
+++ ld/testsuite/ld-powerpc/tlstocso.d 2 Oct 2009 07:05:32 -0000
@@ -8,7 +8,7 @@
Disassembly of section \.text:
-.*:
+.* <00000010\.plt_call\.__tls_get_addr(|_opt)\+0>:
.* f8 41 00 28 std r2,40\(r1\)
.* e9 62 80 70 ld r11,-32656\(r2\)
.* 7d 69 03 a6 mtctr r11
@@ -41,6 +41,7 @@ Disassembly of section \.text:
.* 99 49 00 00 stb r10,0\(r9\)
.* 00 00 00 00 .*
.* 00 01 02 18 .*
+.* <__glink_PLTresolve>:
.* 7d 88 02 a6 mflr r12
.* 42 9f 00 05 bcl- 20,4\*cr7\+so,.*
.* 7d 68 02 a6 mflr r11
Index: ld/testsuite/ld-powerpc/tlstocso.r
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlstocso.r,v
retrieving revision 1.23
diff -u -p -r1.23 tlstocso.r
--- ld/testsuite/ld-powerpc/tlstocso.r 24 Sep 2009 15:56:51 -0000 1.23
+++ ld/testsuite/ld-powerpc/tlstocso.r 2 Oct 2009 07:05:32 -0000
@@ -106,6 +106,8 @@ Symbol table '\.symtab' contains [0-9]+
.* TLS +LOCAL +DEFAULT +7 le5
.* NOTYPE +LOCAL +DEFAULT +11 \.Lie0
.* OBJECT +LOCAL +DEFAULT +ABS _DYNAMIC
+.* NOTYPE +LOCAL +DEFAULT +6 00000010\.plt_call\.__tls_get_addr\+0
+.* NOTYPE +LOCAL +DEFAULT +6 __glink_PLTresolve
.* NOTYPE +LOCAL +DEFAULT +UND \.__tls_get_addr
.* TLS +GLOBAL +DEFAULT +UND gd
.* TLS +GLOBAL +DEFAULT +8 le0
--
Alan Modra
Australia Development Lab, IBM