* [patch] bfd/elflink.c create_got_section fix for rel(a).got
@ 2011-11-09 16:01 Andreas Tobler
2011-11-15 11:23 ` Alan Modra
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Tobler @ 2011-11-09 16:01 UTC (permalink / raw)
To: binutils
All,
The patch below fixes my upcoming powerpc*-freebsd* target when I try to
link against shared libraries.
The problem is the following when I run the test suite I get 'could not
read symbols' 'No error/Format not recognized' when the test tries to
'link in' a shared library. The 'No error' happens in case of a
self-built library, the 'Format not recognized' happens for example for
libc.so
The first file of the link command contains a rela.got section:
readelf -t /usr/lib/crt1.o | grep got
[ 6] .got
[ 7] .rela.got
In my understanding with the existing code ld jumps out with NULL as
soon as ld sees a rel(a).got section. And this leaves my shared library
unrecognized.
I was in contact with Alan and he pointed me to the below solution.
s/bfd_make_section_with_flags/bfd_make_section_anyway_with_flags
The patch was tested on powerpc64-freebsd, x86_64-freebsd and on a
x86_64 GNU/Linux system.
Is this patch ok for trunk? Afaik it also happens on 2.21.
TIA,
Andreas
2011-11-09 Andreas Tobler <andreast@fgznet.ch>
* elflink.c (_bfd_elf_create_got_section): Replace
bfd_make_section_with_flags with bfd_make_section_anyway_with_flags.
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.429
diff -u -r1.429 elflink.c
--- bfd/elflink.c 8 Nov 2011 13:49:11 -0000 1.429
+++ bfd/elflink.c 9 Nov 2011 08:04:43 -0000
@@ -110,17 +110,17 @@
flags = bed->dynamic_sec_flags;
- s = bfd_make_section_with_flags (abfd,
- (bed->rela_plts_and_copies_p
- ? ".rela.got" : ".rel.got"),
- (bed->dynamic_sec_flags
- | SEC_READONLY));
+ s = bfd_make_section_anyway_with_flags (abfd,
+ (bed->rela_plts_and_copies_p
+ ? ".rela.got" : ".rel.got"),
+ (bed->dynamic_sec_flags
+ | SEC_READONLY));
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
htab->srelgot = s;
- s = bfd_make_section_with_flags (abfd, ".got", flags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
if (s == NULL
|| !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
@@ -128,7 +128,7 @@
if (bed->want_got_plt)
{
- s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
if (s == NULL
|| !bfd_set_section_alignment (abfd, s,
bed->s->log_file_align))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] bfd/elflink.c create_got_section fix for rel(a).got
2011-11-09 16:01 [patch] bfd/elflink.c create_got_section fix for rel(a).got Andreas Tobler
@ 2011-11-15 11:23 ` Alan Modra
2011-11-15 19:56 ` Andreas Tobler
0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2011-11-15 11:23 UTC (permalink / raw)
To: Andreas Tobler; +Cc: binutils
On Wed, Nov 09, 2011 at 09:22:24AM +0100, Andreas Tobler wrote:
> * elflink.c (_bfd_elf_create_got_section): Replace
> bfd_make_section_with_flags with bfd_make_section_anyway_with_flags.
Applying mainline and branch, fixing a few more places too.
* elflink.c (_bfd_elf_create_got_section): Replace
bfd_make_section_with_flags with bfd_make_section_anyway_with_flags.
(_bfd_elf_link_create_dynamic_sections): Likewise.
* elf32-ppc.c (ppc_elf_create_glink): Likewise.
(ppc_elf_create_dynamic_sections): Likewise.
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.429
diff -u -p -r1.429 elflink.c
--- bfd/elflink.c 8 Nov 2011 13:49:11 -0000 1.429
+++ bfd/elflink.c 15 Nov 2011 08:32:40 -0000
@@ -110,17 +110,17 @@ _bfd_elf_create_got_section (bfd *abfd,
flags = bed->dynamic_sec_flags;
- s = bfd_make_section_with_flags (abfd,
- (bed->rela_plts_and_copies_p
- ? ".rela.got" : ".rel.got"),
- (bed->dynamic_sec_flags
- | SEC_READONLY));
+ s = bfd_make_section_anyway_with_flags (abfd,
+ (bed->rela_plts_and_copies_p
+ ? ".rela.got" : ".rel.got"),
+ (bed->dynamic_sec_flags
+ | SEC_READONLY));
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
htab->srelgot = s;
- s = bfd_make_section_with_flags (abfd, ".got", flags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
if (s == NULL
|| !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
@@ -128,7 +128,7 @@ _bfd_elf_create_got_section (bfd *abfd,
if (bed->want_got_plt)
{
- s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
if (s == NULL
|| !bfd_set_section_alignment (abfd, s,
bed->s->log_file_align))
@@ -206,44 +206,44 @@ _bfd_elf_link_create_dynamic_sections (b
shared library does not. */
if (info->executable)
{
- s = bfd_make_section_with_flags (abfd, ".interp",
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd, ".interp",
+ flags | SEC_READONLY);
if (s == NULL)
return FALSE;
}
/* Create sections to hold version informations. These are removed
if they are not needed. */
- s = bfd_make_section_with_flags (abfd, ".gnu.version_d",
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd, ".gnu.version_d",
+ flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
- s = bfd_make_section_with_flags (abfd, ".gnu.version",
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd, ".gnu.version",
+ flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 1))
return FALSE;
- s = bfd_make_section_with_flags (abfd, ".gnu.version_r",
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd, ".gnu.version_r",
+ flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
- s = bfd_make_section_with_flags (abfd, ".dynsym",
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd, ".dynsym",
+ flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
- s = bfd_make_section_with_flags (abfd, ".dynstr",
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd, ".dynstr",
+ flags | SEC_READONLY);
if (s == NULL)
return FALSE;
- s = bfd_make_section_with_flags (abfd, ".dynamic", flags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".dynamic", flags);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
@@ -259,7 +259,8 @@ _bfd_elf_link_create_dynamic_sections (b
if (info->emit_hash)
{
- s = bfd_make_section_with_flags (abfd, ".hash", flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd, ".hash",
+ flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
@@ -268,8 +269,8 @@ _bfd_elf_link_create_dynamic_sections (b
if (info->emit_gnu_hash)
{
- s = bfd_make_section_with_flags (abfd, ".gnu.hash",
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd, ".gnu.hash",
+ flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
@@ -320,7 +321,7 @@ _bfd_elf_create_dynamic_sections (bfd *a
if (bed->plt_readonly)
pltflags |= SEC_READONLY;
- s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
return FALSE;
@@ -337,10 +338,10 @@ _bfd_elf_create_dynamic_sections (bfd *a
return FALSE;
}
- s = bfd_make_section_with_flags (abfd,
- (bed->rela_plts_and_copies_p
- ? ".rela.plt" : ".rel.plt"),
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd,
+ (bed->rela_plts_and_copies_p
+ ? ".rela.plt" : ".rel.plt"),
+ flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
@@ -357,9 +358,8 @@ _bfd_elf_create_dynamic_sections (bfd *a
image and use a R_*_COPY reloc to tell the dynamic linker to
initialize them at run time. The linker script puts the .dynbss
section into the .bss section of the final image. */
- s = bfd_make_section_with_flags (abfd, ".dynbss",
- (SEC_ALLOC
- | SEC_LINKER_CREATED));
+ s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+ (SEC_ALLOC | SEC_LINKER_CREATED));
if (s == NULL)
return FALSE;
@@ -376,10 +376,10 @@ _bfd_elf_create_dynamic_sections (bfd *a
copy relocs. */
if (! info->shared)
{
- s = bfd_make_section_with_flags (abfd,
- (bed->rela_plts_and_copies_p
- ? ".rela.bss" : ".rel.bss"),
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd,
+ (bed->rela_plts_and_copies_p
+ ? ".rela.bss" : ".rel.bss"),
+ flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.303
diff -u -p -r1.303 elf32-ppc.c
--- bfd/elf32-ppc.c 19 Oct 2011 07:17:14 -0000 1.303
+++ bfd/elf32-ppc.c 15 Nov 2011 08:32:38 -0000
@@ -2891,7 +2891,7 @@ ppc_elf_create_glink (bfd *abfd, struct
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
- s = bfd_make_section_with_flags (abfd, ".rela.iplt", flags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".rela.iplt", flags);
htab->reliplt = s;
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 2))
@@ -2924,8 +2924,8 @@ ppc_elf_create_dynamic_sections (bfd *ab
return FALSE;
htab->dynbss = bfd_get_section_by_name (abfd, ".dynbss");
- s = bfd_make_section_with_flags (abfd, ".dynsbss",
- SEC_ALLOC | SEC_LINKER_CREATED);
+ s = bfd_make_section_anyway_with_flags (abfd, ".dynsbss",
+ SEC_ALLOC | SEC_LINKER_CREATED);
htab->dynsbss = s;
if (s == NULL)
return FALSE;
@@ -2935,7 +2935,7 @@ ppc_elf_create_dynamic_sections (bfd *ab
htab->relbss = bfd_get_section_by_name (abfd, ".rela.bss");
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
- s = bfd_make_section_with_flags (abfd, ".rela.sbss", flags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".rela.sbss", flags);
htab->relsbss = s;
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 2))
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] bfd/elflink.c create_got_section fix for rel(a).got
2011-11-15 11:23 ` Alan Modra
@ 2011-11-15 19:56 ` Andreas Tobler
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Tobler @ 2011-11-15 19:56 UTC (permalink / raw)
To: binutils
On 15.11.11 12:22, Alan Modra wrote:
> On Wed, Nov 09, 2011 at 09:22:24AM +0100, Andreas Tobler wrote:
>> * elflink.c (_bfd_elf_create_got_section): Replace
>> bfd_make_section_with_flags with bfd_make_section_anyway_with_flags.
>
> Applying mainline and branch, fixing a few more places too.
>
> * elflink.c (_bfd_elf_create_got_section): Replace
> bfd_make_section_with_flags with bfd_make_section_anyway_with_flags.
> (_bfd_elf_link_create_dynamic_sections): Likewise.
> * elf32-ppc.c (ppc_elf_create_glink): Likewise.
> (ppc_elf_create_dynamic_sections): Likewise.
Thanks a lot!
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-15 19:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-09 16:01 [patch] bfd/elflink.c create_got_section fix for rel(a).got Andreas Tobler
2011-11-15 11:23 ` Alan Modra
2011-11-15 19:56 ` Andreas Tobler
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).