summaryrefslogtreecommitdiff
path: root/ld/ldemul.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2009-09-13 07:19:18 +0000
committerAlan Modra <amodra@bigpond.net.au>2009-09-13 07:19:18 +0000
commitd6e79dde0a5f39fb1eb7505698dcc229341f618f (patch)
tree45de6ef54206e7f0458aebfd51e9eb7f155e043d /ld/ldemul.c
parent5baaae55aa9003c0d2be62d9165ec4629c1cf7c8 (diff)
downloadbinutils-redhat-d6e79dde0a5f39fb1eb7505698dcc229341f618f.tar.gz
PR ld/6766
* lexsup.c (parse_args <-e>): Revert 2009-03-18 change. * ldemul.c (after_parse_default): Add entry symbol as undef. * emultempl/alphaelf.em (alpha_after_parse): Call after_parse_default. * emultempl/cr16elf.em (cr16elf_after_parse): Likewise. * emultempl/crxelf.em (crxelf_after_parse): Likewise. * emultempl/hppaelf.em (hppaelf_after_parse): Likewise. * emultempl/ia64elf.em (gld${EMULATION_NAME}_after_parse): Likewise. * emultempl/pe.em (gld_${EMULATION_NAME}_after_parse): Call after_parse_default and delete now duplicate code. * emultempl/pep.em (gld_${EMULATION_NAME}_after_parse): Likewise. * scripttempl/elf32cr16.sc: No need to make entry extern. * scripttempl/elf32cr16c.sc: Likewise. * scripttempl/elf32crx.sc: Likewise. * scripttempl/elf32xc16xs.sc: Only provide ENTRY on final link.
Diffstat (limited to 'ld/ldemul.c')
-rw-r--r--ld/ldemul.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/ld/ldemul.c b/ld/ldemul.c
index b29703627f..c77eeb0eb5 100644
--- a/ld/ldemul.c
+++ b/ld/ldemul.c
@@ -192,9 +192,35 @@ ldemul_default_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
return ld_emulation->target_name;
}
+/* If the entry point was not specified as an address, then add the
+ symbol as undefined. This will cause ld to extract an archive
+ element defining the entry if ld is linking against such an archive.
+
+ We don't do this when generating shared libraries unless given -e
+ on the command line, because most shared libs are not designed to
+ be run as an executable. However, some are, eg. glibc ld.so and
+ may rely on the default linker script supplying ENTRY. So we can't
+ remove the ENTRY from the script, but would rather not insert
+ undefined _start syms. */
+
void
after_parse_default (void)
{
+ if (entry_symbol.name != NULL
+ && (link_info.executable || entry_from_cmdline))
+ {
+ bfd_boolean is_vma = FALSE;
+
+ if (entry_from_cmdline)
+ {
+ const char *send;
+
+ bfd_scan_vma (entry_symbol.name, &send, 0);
+ is_vma = *send == '\0';
+ }
+ if (!is_vma)
+ ldlang_add_undef (entry_symbol.name);
+ }
}
void