* [PATCH] Fix ppc64 .note.GNU-stack handling
@ 2005-02-09 22:18 Jakub Jelinek
2005-02-10 9:59 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2005-02-09 22:18 UTC (permalink / raw)
To: binutils
Hi!
.note.GNU-stack section handling is broken on ppc64 (and probably on hppa as
well). If there are any .note.GNU-stack sections in the input, then
all of them must have that section and without SEC_CODE, otherwise the
result is executable. But on ppc64 there is a linker stubs magic bfd
synthetized by the linker that never has this section, so if there are
any .note.GNU-stack sections, whether executable or not, the result
is PT_GNU_STACK RWE.
Fixed thusly, ok to commit?
2005-02-09 Jakub Jelinek <jakub@redhat.com>
* bfd-in.h (BFD_LINKER_CREATED): Define.
* bfd-in2.h: Rebuilt.
* elflink.c (bfd_elf_size_dynamic_sections): Disregard
BFD_LINKER_CREATED bfds when determining input bfds without
.note.GNU-stack section.
* emultempl/hppaelf.em (hppaelf_create_output_section_statements):
Set BFD_LINKER_CREATED on the stubs bfd.
* emultempl/ppc64elf.em (ppc_create_output_section_statements):
Likewise.
--- bfd/bfd-in.h.jj 2005-02-09 16:06:50.000000000 +0100
+++ bfd/bfd-in.h 2005-02-09 17:44:34.000000000 +0100
@@ -1,7 +1,7 @@
/* Main header file for the bfd library -- portable access to object files.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Cygnus Support.
@@ -230,6 +230,10 @@ bfd_format;
/* The sections in this BFD specify a memory page. */
#define HAS_LOAD_PAGE 0x1000
+
+/* This BFD has been created by the linker and doesn't correspond
+ to any input file. */
+#define BFD_LINKER_CREATED 0x2000
\f
/* Symbols and relocation. */
--- bfd/bfd-in2.h.jj 2005-02-09 16:06:50.000000000 +0100
+++ bfd/bfd-in2.h 2005-02-09 17:45:09.698719811 +0100
@@ -8,7 +8,7 @@
/* Main header file for the bfd library -- portable access to object files.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Cygnus Support.
@@ -245,6 +245,10 @@ bfd_format;
/* The sections in this BFD specify a memory page. */
#define HAS_LOAD_PAGE 0x1000
+
+/* This BFD has been created by the linker and doesn't correspond
+ to any input file. */
+#define BFD_LINKER_CREATED 0x2000
\f
/* Symbols and relocation. */
--- bfd/elflink.c.jj 2005-02-09 16:06:57.000000000 +0100
+++ bfd/elflink.c 2005-02-09 17:47:45.209950411 +0100
@@ -4895,7 +4895,7 @@ bfd_elf_size_dynamic_sections (bfd *outp
{
asection *s;
- if (inputobj->flags & DYNAMIC)
+ if (inputobj->flags & (DYNAMIC | BFD_LINKER_CREATED))
continue;
s = bfd_get_section_by_name (inputobj, ".note.GNU-stack");
if (s)
--- ld/emultempl/hppaelf.em.jj 2005-01-21 13:01:18.000000000 +0100
+++ ld/emultempl/hppaelf.em 2005-02-09 17:46:46.442444375 +0100
@@ -88,6 +88,7 @@ hppaelf_create_output_section_statements
return;
}
+ stub_file->the_bfd->flags |= BFD_LINKER_CREATED;
ldlang_add_file (stub_file);
}
--- ld/emultempl/ppc64elf.em.jj 2005-01-20 09:50:47.000000000 +0100
+++ ld/emultempl/ppc64elf.em 2005-02-09 17:47:11.103040786 +0100
@@ -92,6 +92,7 @@ ppc_create_output_section_statements (vo
return;
}
+ stub_file->the_bfd->flags |= BFD_LINKER_CREATED;
ldlang_add_file (stub_file);
ppc64_elf_init_stub_bfd (stub_file->the_bfd, &link_info);
}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix ppc64 .note.GNU-stack handling
2005-02-09 22:18 [PATCH] Fix ppc64 .note.GNU-stack handling Jakub Jelinek
@ 2005-02-10 9:59 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2005-02-10 9:59 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: binutils
On Wed, Feb 09, 2005 at 08:02:18PM +0100, Jakub Jelinek wrote:
> * bfd-in.h (BFD_LINKER_CREATED): Define.
> * bfd-in2.h: Rebuilt.
> * elflink.c (bfd_elf_size_dynamic_sections): Disregard
> BFD_LINKER_CREATED bfds when determining input bfds without
> .note.GNU-stack section.
>
> * emultempl/hppaelf.em (hppaelf_create_output_section_statements):
> Set BFD_LINKER_CREATED on the stubs bfd.
> * emultempl/ppc64elf.em (ppc_create_output_section_statements):
> Likewise.
OK. Thanks!
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-02-09 23:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-09 22:18 [PATCH] Fix ppc64 .note.GNU-stack handling Jakub Jelinek
2005-02-10 9:59 ` Alan Modra
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).