aboutsummaryrefslogtreecommitdiff
path: root/ld
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
parent5335ab68727bbce11c452e3b6bcbfc1ed32f65fd (diff)
downloadgdb-5226a6a892f922ea672e5775c61776830aaf27b7.zip
gdb-5226a6a892f922ea672e5775c61776830aaf27b7.tar.gz
gdb-5226a6a892f922ea672e5775c61776830aaf27b7.tar.bz2
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')
-rw-r--r--ld/ChangeLog27
-rw-r--r--ld/ld.texi4
-rw-r--r--ld/ldlang.c10
-rw-r--r--ld/testsuite/ld-alpha/tlspic.rd2
-rw-r--r--ld/testsuite/ld-arm/tls-gdesc-got.d2
-rw-r--r--ld/testsuite/ld-i386/tlsnopic.rd2
-rw-r--r--ld/testsuite/ld-ia64/tlspic.rd2
-rw-r--r--ld/testsuite/ld-sparc/gotop32.rd2
-rw-r--r--ld/testsuite/ld-sparc/gotop64.rd2
-rw-r--r--ld/testsuite/ld-sparc/tlssunnopic32.rd2
-rw-r--r--ld/testsuite/ld-sparc/tlssunnopic64.rd2
-rw-r--r--ld/testsuite/ld-sparc/tlssunpic32.rd2
-rw-r--r--ld/testsuite/ld-sparc/tlssunpic64.rd2
-rw-r--r--ld/testsuite/ld-tic6x/shlib-1.rd2
-rw-r--r--ld/testsuite/ld-tic6x/shlib-1b.rd2
-rw-r--r--ld/testsuite/ld-tic6x/shlib-1r.rd2
-rw-r--r--ld/testsuite/ld-tic6x/shlib-1rb.rd2
-rw-r--r--ld/testsuite/ld-tic6x/shlib-noindex.rd2
-rw-r--r--ld/testsuite/ld-x86-64/pr14207.d2
-rw-r--r--ld/testsuite/ld-x86-64/tlsdesc.rd2
-rw-r--r--ld/testsuite/ld-x86-64/tlspic.rd2
-rw-r--r--ld/testsuite/ld-x86-64/tlspic2.rd2
22 files changed, 58 insertions, 21 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 2733da1..9be239d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,30 @@
+2021-09-21 Nick Clifton <nickc@redhat.com>
+
+ * 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.
+
2021-09-15 Claudiu Zissulescu <claziss@synopsys.com>
* testsuite/ld-arc/got-weak.d: Update file.
diff --git a/ld/ld.texi b/ld/ld.texi
index 72b5c37..db410f0 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -3910,7 +3910,9 @@ the value of a target-specific symbol, if it is defined; For many
targets this is @code{start}, but PE- and BeOS-based systems for example
check a list of possible entry symbols, matching the first one found.
@item
-the address of the first byte of the @samp{.text} section, if present;
+the address of the first byte of the code section, if present and an
+executable is being created - the code section is usually
+@samp{.text}, but can be something else;
@item
The address @code{0}.
@end itemize
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 2610be9..bc3f8b7 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);
+ }
}
}
diff --git a/ld/testsuite/ld-alpha/tlspic.rd b/ld/testsuite/ld-alpha/tlspic.rd
index b79fc71..a19df37 100644
--- a/ld/testsuite/ld-alpha/tlspic.rd
+++ b/ld/testsuite/ld-alpha/tlspic.rd
@@ -29,7 +29,7 @@ Section Headers:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-arm/tls-gdesc-got.d b/ld/testsuite/ld-arm/tls-gdesc-got.d
index 873d11f..38efaa8 100644
--- a/ld/testsuite/ld-arm/tls-gdesc-got.d
+++ b/ld/testsuite/ld-arm/tls-gdesc-got.d
@@ -2,7 +2,7 @@
.*/tls-lib2-got.so: file format elf32-.*arm.*
architecture: arm.*, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
-start address 0x0+8(1e8|220)
+start address 0x[0-9a-f]+
Disassembly of section .got:
diff --git a/ld/testsuite/ld-i386/tlsnopic.rd b/ld/testsuite/ld-i386/tlsnopic.rd
index 229ce23..719e44d 100644
--- a/ld/testsuite/ld-i386/tlsnopic.rd
+++ b/ld/testsuite/ld-i386/tlsnopic.rd
@@ -26,7 +26,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-ia64/tlspic.rd b/ld/testsuite/ld-ia64/tlspic.rd
index 02c9800..4b6e76e 100644
--- a/ld/testsuite/ld-ia64/tlspic.rd
+++ b/ld/testsuite/ld-ia64/tlspic.rd
@@ -31,7 +31,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-sparc/gotop32.rd b/ld/testsuite/ld-sparc/gotop32.rd
index 0f02e91..a6b7107 100644
--- a/ld/testsuite/ld-sparc/gotop32.rd
+++ b/ld/testsuite/ld-sparc/gotop32.rd
@@ -23,7 +23,7 @@ Section Headers:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-sparc/gotop64.rd b/ld/testsuite/ld-sparc/gotop64.rd
index 249d731..22b3769 100644
--- a/ld/testsuite/ld-sparc/gotop64.rd
+++ b/ld/testsuite/ld-sparc/gotop64.rd
@@ -23,7 +23,7 @@ Section Headers:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-sparc/tlssunnopic32.rd b/ld/testsuite/ld-sparc/tlssunnopic32.rd
index 01f8933..5574868 100644
--- a/ld/testsuite/ld-sparc/tlssunnopic32.rd
+++ b/ld/testsuite/ld-sparc/tlssunnopic32.rd
@@ -23,7 +23,7 @@ Section Headers:
+\[[ 0-9]+\] .shstrtab +.*
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-sparc/tlssunnopic64.rd b/ld/testsuite/ld-sparc/tlssunnopic64.rd
index 8104c67..cadc77c 100644
--- a/ld/testsuite/ld-sparc/tlssunnopic64.rd
+++ b/ld/testsuite/ld-sparc/tlssunnopic64.rd
@@ -23,7 +23,7 @@ Section Headers:
+\[[ 0-9]+\] .shstrtab +.*
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-sparc/tlssunpic32.rd b/ld/testsuite/ld-sparc/tlssunpic32.rd
index d401262..7ad8c99 100644
--- a/ld/testsuite/ld-sparc/tlssunpic32.rd
+++ b/ld/testsuite/ld-sparc/tlssunpic32.rd
@@ -27,7 +27,7 @@ Section Headers:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-sparc/tlssunpic64.rd b/ld/testsuite/ld-sparc/tlssunpic64.rd
index 5816205..61f84c5 100644
--- a/ld/testsuite/ld-sparc/tlssunpic64.rd
+++ b/ld/testsuite/ld-sparc/tlssunpic64.rd
@@ -27,7 +27,7 @@ Section Headers:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-tic6x/shlib-1.rd b/ld/testsuite/ld-tic6x/shlib-1.rd
index 6b64d01..9ad2396 100644
--- a/ld/testsuite/ld-tic6x/shlib-1.rd
+++ b/ld/testsuite/ld-tic6x/shlib-1.rd
@@ -23,7 +23,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x10000080
+Entry point 0x[0-9a-f]+
There are 4 program headers, starting at offset 52
Program Headers:
diff --git a/ld/testsuite/ld-tic6x/shlib-1b.rd b/ld/testsuite/ld-tic6x/shlib-1b.rd
index 6b64d01..9ad2396 100644
--- a/ld/testsuite/ld-tic6x/shlib-1b.rd
+++ b/ld/testsuite/ld-tic6x/shlib-1b.rd
@@ -23,7 +23,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x10000080
+Entry point 0x[0-9a-f]+
There are 4 program headers, starting at offset 52
Program Headers:
diff --git a/ld/testsuite/ld-tic6x/shlib-1r.rd b/ld/testsuite/ld-tic6x/shlib-1r.rd
index 6b64d01..9ad2396 100644
--- a/ld/testsuite/ld-tic6x/shlib-1r.rd
+++ b/ld/testsuite/ld-tic6x/shlib-1r.rd
@@ -23,7 +23,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x10000080
+Entry point 0x[0-9a-f]+
There are 4 program headers, starting at offset 52
Program Headers:
diff --git a/ld/testsuite/ld-tic6x/shlib-1rb.rd b/ld/testsuite/ld-tic6x/shlib-1rb.rd
index 6b64d01..9ad2396 100644
--- a/ld/testsuite/ld-tic6x/shlib-1rb.rd
+++ b/ld/testsuite/ld-tic6x/shlib-1rb.rd
@@ -23,7 +23,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x10000080
+Entry point 0x[0-9a-f]+
There are 4 program headers, starting at offset 52
Program Headers:
diff --git a/ld/testsuite/ld-tic6x/shlib-noindex.rd b/ld/testsuite/ld-tic6x/shlib-noindex.rd
index 38934ba..f087d15 100644
--- a/ld/testsuite/ld-tic6x/shlib-noindex.rd
+++ b/ld/testsuite/ld-tic6x/shlib-noindex.rd
@@ -24,7 +24,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x10000080
+Entry point 0x[0-9a-f]+
There are 4 program headers, starting at offset 52
Program Headers:
diff --git a/ld/testsuite/ld-x86-64/pr14207.d b/ld/testsuite/ld-x86-64/pr14207.d
index 1713888..f330600 100644
--- a/ld/testsuite/ld-x86-64/pr14207.d
+++ b/ld/testsuite/ld-x86-64/pr14207.d
@@ -5,7 +5,7 @@
#target: x86_64-*-linux*
Elf file type is DYN \(Shared object file\)
-Entry point 0x149
+Entry point 0x[0-9a-f]+
There are 4 program headers, starting at offset 64
Program Headers:
diff --git a/ld/testsuite/ld-x86-64/tlsdesc.rd b/ld/testsuite/ld-x86-64/tlsdesc.rd
index 58feb20..98bda5b 100644
--- a/ld/testsuite/ld-x86-64/tlsdesc.rd
+++ b/ld/testsuite/ld-x86-64/tlsdesc.rd
@@ -29,7 +29,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-x86-64/tlspic.rd b/ld/testsuite/ld-x86-64/tlspic.rd
index 2e44dc6..e5d991a 100644
--- a/ld/testsuite/ld-x86-64/tlspic.rd
+++ b/ld/testsuite/ld-x86-64/tlspic.rd
@@ -29,7 +29,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers:
diff --git a/ld/testsuite/ld-x86-64/tlspic2.rd b/ld/testsuite/ld-x86-64/tlspic2.rd
index 60decd2..4c20f3b 100644
--- a/ld/testsuite/ld-x86-64/tlspic2.rd
+++ b/ld/testsuite/ld-x86-64/tlspic2.rd
@@ -29,7 +29,7 @@ Key to Flags:
#...
Elf file type is DYN \(Shared object file\)
-Entry point 0x1000
+Entry point 0x[0-9a-f]+
There are [0-9]+ program headers, starting at offset [0-9]+
Program Headers: