This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Create ".dynamic" section earlier


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]