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]

Re: [PATCH] Issues with ld -shared --build-id


On Tue, Jul 24, 2007 at 04:10:47PM -0700, Roland McGrath wrote:
> IIUC the proper orphans placing would put it (SHT_NOTE,SHF_ALLOC) there
> anyway.

This ldlang.c patch fixes the problem Jakub reported, with orphan note
sections being placed before the initial "dot" assignment in a linker
script.  The elf32.em patch improves placement of orphan reloc
sections.

ld/
	* ldlang.c (lang_insert_orphan): When searching through linker
	script to place an orphan, don't stop on statements that appear
	outside of SECTIONS.
	* emultempl/elf32.em (output_rel_find): Prefer read-only alloc
	sections over read/write alloc sections.
ld/testsuite/
	* ld-elf/weak-dyn-1.rd: Adjust.

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.267
diff -u -p -r1.267 ldlang.c
--- ld/ldlang.c	13 Jul 2007 07:34:25 -0000	1.267
+++ ld/ldlang.c	29 Jul 2007 02:52:28 -0000
@@ -1654,13 +1654,14 @@ lang_insert_orphan (asection *s,
 		    case lang_output_section_statement_enum:
 		      if (assign != NULL)
 			where = assign;
+		      break;
 		    case lang_input_statement_enum:
 		    case lang_address_statement_enum:
 		    case lang_target_statement_enum:
 		    case lang_output_statement_enum:
 		    case lang_group_statement_enum:
 		    case lang_afile_asection_pair_statement_enum:
-		      break;
+		      continue;
 		    }
 		  break;
 		}
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.183
diff -u -p -r1.183 elf32.em
--- ld/emultempl/elf32.em	19 Jul 2007 19:56:10 -0000	1.183
+++ ld/emultempl/elf32.em	29 Jul 2007 02:52:30 -0000
@@ -1567,6 +1567,7 @@ output_rel_find (asection *sec, int isdy
   lang_output_section_statement_type *lookup;
   lang_output_section_statement_type *last = NULL;
   lang_output_section_statement_type *last_alloc = NULL;
+  lang_output_section_statement_type *last_ro_alloc = NULL;
   lang_output_section_statement_type *last_rel = NULL;
   lang_output_section_statement_type *last_rel_alloc = NULL;
   int rela = sec->name[4] == 'a';
@@ -1601,7 +1602,11 @@ output_rel_find (asection *sec, int isdy
       last = lookup;
       if (lookup->bfd_section != NULL
 	  && (lookup->bfd_section->flags & SEC_ALLOC) != 0)
-	last_alloc = lookup;
+	{
+	  last_alloc = lookup;
+	  if ((lookup->bfd_section->flags & SEC_READONLY) != 0)
+	    last_ro_alloc = lookup;
+	}
     }
 
   if (last_rel_alloc)
@@ -1610,6 +1615,9 @@ output_rel_find (asection *sec, int isdy
   if (last_rel)
     return last_rel;
 
+  if (last_ro_alloc)
+    return last_ro_alloc;
+
   if (last_alloc)
     return last_alloc;
 
Index: ld/testsuite/ld-elf/weak-dyn-1.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/weak-dyn-1.rd,v
retrieving revision 1.1
diff -u -p -r1.1 weak-dyn-1.rd
--- ld/testsuite/ld-elf/weak-dyn-1.rd	23 Jul 2007 09:56:19 -0000	1.1
+++ ld/testsuite/ld-elf/weak-dyn-1.rd	29 Jul 2007 08:17:42 -0000
@@ -1,3 +1,3 @@
 #...
-0+800000 .* foo.*
+.* foo.*
 #pass


-- 
Alan Modra
Australia Development Lab, IBM


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