This is the mail archive of the binutils@sources.redhat.com 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: Unreviewed patch


On Wed, Dec 04, 2002 at 04:54:31PM +1030, Alan Modra wrote:
> I reckon SIZEOF is behaving correctly now..  You could set your lma from
> the vma, like
> 
>   .data : AT (ADDR (.data) + 0x10000000) { *(.data) }
> 
> That still doesn't solve your orphan section problem though.  :-(

This does though.  Committing mainline.

	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Set
	load_base for orphans that follow a section with load_base set.

pe.em and mmo.em may want a similar fix.  I'll leave that to the
respective maintainers to decide.

Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.85
diff -u -p -r1.85 elf32.em
--- ld/emultempl/elf32.em	30 Nov 2002 08:39:46 -0000	1.85
+++ ld/emultempl/elf32.em	4 Dec 2002 23:14:45 -0000
@@ -1093,6 +1093,7 @@ gld${EMULATION_NAME}_place_orphan (file,
   const char *secname;
   const char *ps = NULL;
   lang_output_section_statement_type *os;
+  etree_type *load_base;
   int isdyn = 0;
 
   secname = bfd_get_section_name (s->owner, s);
@@ -1227,16 +1228,25 @@ gld${EMULATION_NAME}_place_orphan (file,
 	}
     }
 
+  address = NULL;
   if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
     address = exp_intop ((bfd_vma) 0);
-  else
-    address = NULL;
+
+  load_base = NULL;
+  if (place != NULL && place->os->load_base != NULL)
+    {
+      etree_type *lma_from_vma;
+      lma_from_vma = exp_binop ('-', place->os->load_base,
+				exp_nameop (ADDR, place->os->name));
+      load_base = exp_binop ('+', lma_from_vma,
+			     exp_nameop (ADDR, secname));
+    }
 
   os = lang_enter_output_section_statement (secname, address, 0,
 					    (bfd_vma) 0,
 					    (etree_type *) NULL,
 					    (etree_type *) NULL,
-					    (etree_type *) NULL);
+					    load_base);
 
   lang_add_section (&os->children, s, os, file);
 


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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