From 36478e9d6fdfc553b21fa060bf791c5e900db693 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 4 Dec 2002 23:56:14 +0000 Subject: * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Set load_base for orphans that follow a section with load_base set. --- ld/emultempl/elf32.em | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'ld/emultempl') diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 60a789e..06fdd81 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1093,6 +1093,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) 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, s) } } + 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); -- cgit v1.1