* [PATCH] Create ".dynamic" section earlier
@ 2006-06-09 14:43 Fred Fish
2006-06-09 15:38 ` H. J. Lu
0 siblings, 1 reply; 6+ messages in thread
From: Fred Fish @ 2006-06-09 14:43 UTC (permalink / raw)
To: binutils; +Cc: fnf
When testing gdb for various mips*-elf toolchains I'm getting link errors like the following
edited message:
gdb compile failed, ld: gdb1555.so: The first section in the PT_DYNAMIC segment is not the .dynamic section
ld: final link failed: Bad value
collect2: ld returned 1 exit status
Attached is a patch that fixes it, though I'm not sure it is the best
way to handle the issue.
-Fred
2006-06-05 Fred Fish <fnf@specifix.com>
* elflink.c (_bfd_elf_link_create_dynamic_sections): Create
the ".dynamic" section earlier, so it ends up as the first
section in the PT_DYNAMIC segment, a condition enforced by
the linker.
Index: binutils/bfd/elflink.c
===================================================================
RCS file: /cvsroots/latest/src/binutils/bfd/elflink.c,v
retrieving revision 1.1.1.16
diff -u -p -r1.1.1.16 elflink.c
--- binutils/bfd/elflink.c 28 May 2006 10:10:47 -0000 1.1.1.16
+++ binutils/bfd/elflink.c 5 Jun 2006 16:39:06 -0000
@@ -215,6 +215,11 @@ _bfd_elf_link_create_dynamic_sections (b
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
+ s = bfd_make_section_with_flags (abfd, ".dynamic", flags);
+ 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);
if (s == NULL
@@ -226,11 +231,6 @@ _bfd_elf_link_create_dynamic_sections (b
if (s == NULL)
return FALSE;
- s = bfd_make_section_with_flags (abfd, ".dynamic", flags);
- if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
- return FALSE;
-
/* The special symbol _DYNAMIC is always set to the start of the
.dynamic section. We could set _DYNAMIC in a linker script, but we
only want to define it if we are, in fact, creating a .dynamic
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Create ".dynamic" section earlier
2006-06-09 14:43 [PATCH] Create ".dynamic" section earlier Fred Fish
@ 2006-06-09 15:38 ` H. J. Lu
2006-06-09 15:46 ` Fred Fish
0 siblings, 1 reply; 6+ messages in thread
From: H. J. Lu @ 2006-06-09 15:38 UTC (permalink / raw)
To: Fred Fish; +Cc: binutils
On Fri, Jun 09, 2006 at 10:14:24AM -0400, Fred Fish wrote:
> When testing gdb for various mips*-elf toolchains I'm getting link errors like the following
> edited message:
>
> gdb compile failed, ld: gdb1555.so: The first section in the PT_DYNAMIC segment is not the .dynamic section
> ld: final link failed: Bad value
> collect2: ld returned 1 exit status
>
> Attached is a patch that fixes it, though I'm not sure it is the best
> way to handle the issue.
>
I have seen similar one before. I thought I fixed it with
http://sourceware.org/ml/binutils/2006-05/msg00508.html
I may have missed this one. Do you have a testcase?
H.J.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Create ".dynamic" section earlier
2006-06-09 15:38 ` H. J. Lu
@ 2006-06-09 15:46 ` Fred Fish
2006-06-09 16:53 ` H. J. Lu
2006-06-09 19:16 ` Daniel Jacobowitz
0 siblings, 2 replies; 6+ messages in thread
From: Fred Fish @ 2006-06-09 15:46 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils
On Friday 09 June 2006 11:03, H. J. Lu wrote:
> I may have missed this one. Do you have a testcase?
Here's a simple one:
$ cat main.c
main ()
{
}
$ mips-elf-gcc -shared -o main main.c -Tidt.ld
/links/opt-local/latest/trunk/bin/../lib/gcc/mips-elf/4.2.0/../../../../mips-elf/bin/ld: main: The first section in the PT_DYNAMIC segment is not the .dynamic section
/links/opt-local/latest/trunk/bin/../lib/gcc/mips-elf/4.2.0/../../../../mips-elf/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Create ".dynamic" section earlier
2006-06-09 15:46 ` Fred Fish
@ 2006-06-09 16:53 ` H. J. Lu
2006-06-09 17:08 ` Fred Fish
2006-06-09 19:16 ` Daniel Jacobowitz
1 sibling, 1 reply; 6+ messages in thread
From: H. J. Lu @ 2006-06-09 16:53 UTC (permalink / raw)
To: Fred Fish; +Cc: binutils
On Fri, Jun 09, 2006 at 11:40:09AM -0400, Fred Fish wrote:
> On Friday 09 June 2006 11:03, H. J. Lu wrote:
> > I may have missed this one. Do you have a testcase?
>
> Here's a simple one:
>
> $ cat main.c
> main ()
> {
> }
>
> $ mips-elf-gcc -shared -o main main.c -Tidt.ld
> /links/opt-local/latest/trunk/bin/../lib/gcc/mips-elf/4.2.0/../../../../mips-elf/bin/ld: main: The first section in the PT_DYNAMIC segment is not the .dynamic section
> /links/opt-local/latest/trunk/bin/../lib/gcc/mips-elf/4.2.0/../../../../mips-elf/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
I don't have mips-elf-gcc. Can you provide all linker inputs, including
idt.ld?
H.J.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Create ".dynamic" section earlier
2006-06-09 16:53 ` H. J. Lu
@ 2006-06-09 17:08 ` Fred Fish
0 siblings, 0 replies; 6+ messages in thread
From: Fred Fish @ 2006-06-09 17:08 UTC (permalink / raw)
To: H. J. Lu; +Cc: binutils, fnf
On Friday 09 June 2006 12:38, H. J. Lu wrote:
> I don't have mips-elf-gcc. Can you provide all linker inputs, including
> idt.ld?
OK.
Here's how to reproduce it:
$ tar -xvzf link-kit.tgz
crtbegin.o
crtend.o
crti.o
crtn.o
idt.ld
libgcc.a
link.sh
main.o
$ sh -x link.sh
+ mips-elf-ld -EB -shared -o main crti.o crtbegin.o main.o libgcc.a crtend.o crtn.o -Tidt.ld
mips-elf-ld: main: The first section in the PT_DYNAMIC segment is not the .dynamic section
mips-elf-ld: final link failed: Bad value
I'll email you the link-kit.tgz file separately.
-Fred
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Create ".dynamic" section earlier
2006-06-09 15:46 ` Fred Fish
2006-06-09 16:53 ` H. J. Lu
@ 2006-06-09 19:16 ` Daniel Jacobowitz
1 sibling, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2006-06-09 19:16 UTC (permalink / raw)
To: Fred Fish; +Cc: H. J. Lu, binutils
On Fri, Jun 09, 2006 at 11:40:09AM -0400, Fred Fish wrote:
> $ mips-elf-gcc -shared -o main main.c -Tidt.ld
> /links/opt-local/latest/trunk/bin/../lib/gcc/mips-elf/4.2.0/../../../../mips-elf/bin/ld: main: The first section in the PT_DYNAMIC segment is not the .dynamic section
> /links/opt-local/latest/trunk/bin/../lib/gcc/mips-elf/4.2.0/../../../../mips-elf/bin/ld: final link failed: Bad value
> collect2: ld returned 1 exit status
This problem, of course, only arises because the .dynamic section is
not in your linker script. If you were using the standard linker
scripts generated by the ld build process, it would probably work.
The problem is that the parameter file for mips-elf has
GENERATE_SHLIB_SCRIPT=yes, so -shared is allowed by the linker, but
you're using a handwritten (from libgloss) linker script that doesn't.
So orphan placement is kicking in.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-06-09 18:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-09 14:43 [PATCH] Create ".dynamic" section earlier Fred Fish
2006-06-09 15:38 ` H. J. Lu
2006-06-09 15:46 ` Fred Fish
2006-06-09 16:53 ` H. J. Lu
2006-06-09 17:08 ` Fred Fish
2006-06-09 19:16 ` Daniel Jacobowitz
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).