summaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2021-09-21 13:21:41 +0100
committerNick Clifton <nickc@redhat.com>2021-09-21 13:21:41 +0100
commit5226a6a892f922ea672e5775c61776830aaf27b7 (patch)
treed8eab33ecd70157a381137136bab18a85a5aa1b2 /ld/ldlang.c
parent5335ab68727bbce11c452e3b6bcbfc1ed32f65fd (diff)
downloadbinutils-gdb-5226a6a892f922ea672e5775c61776830aaf27b7.tar.gz
Change the linker's heuristic for computing the entry point for binaries so that shared libraries default to an entry point of 0.
* ldlang.c (lang_end): When computing the entry point, only try the start address of the entry section when creating an executable. * ld.texi (Entry point): Update description of heuristic used to choose the entry point. testsuite/ld-alpha/tlspic.rd: Update expected entry point address. testsuite/ld-arm/tls-gdesc-got.d: Likewise. testsuite/ld-i386/tlsnopic.rd: Likewise. testsuite/ld-ia64/tlspic.rd: Likewise. testsuite/ld-sparc/gotop32.rd: Likewise. testsuite/ld-sparc/gotop64.rd: Likewise. testsuite/ld-sparc/tlssunnopic32.rd: Likewise. testsuite/ld-sparc/tlssunnopic64.rd: Likewise. testsuite/ld-sparc/tlssunpic32.rd: Likewise. testsuite/ld-sparc/tlssunpic64.rd: Likewise. testsuite/ld-tic6x/shlib-1.rd: Likewise. testsuite/ld-tic6x/shlib-1b.rd: Likewise. testsuite/ld-tic6x/shlib-1r.rd: Likewise. testsuite/ld-tic6x/shlib-1rb.rd: Likewise. testsuite/ld-tic6x/shlib-noindex.rd: Likewise. testsuite/ld-x86-64/pr14207.d: Likewise. testsuite/ld-x86-64/tlsdesc.rd: Likewise. testsuite/ld-x86-64/tlspic.rd: Likewise. testsuite/ld-x86-64/tlspic2.rd: Likewise.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 2610be995ca..bc3f8b76d35 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -6984,7 +6984,8 @@ lang_end (void)
if (!bfd_set_start_address (link_info.output_bfd, val))
einfo (_("%F%P: can't set start address\n"));
}
- else
+ /* BZ 2004952: Only use the start of the entry section for executables. */
+ else if bfd_link_executable (&link_info)
{
asection *ts;
@@ -7010,6 +7011,13 @@ lang_end (void)
entry_symbol.name);
}
}
+ else
+ {
+ if (warn)
+ einfo (_("%P: warning: cannot find entry symbol %s;"
+ " not setting start address\n"),
+ entry_symbol.name);
+ }
}
}