diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-08-06 08:18:53 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-08-06 08:19:04 -0700 |
commit | a4819f54c0006554179631189131080be859eefb (patch) | |
tree | f6058c1da96aa3065bba0be6352946163aa5186d /ld/testsuite | |
parent | e2a084f2c152f6358ba926df22a313d3ef8d8509 (diff) | |
download | gdb-a4819f54c0006554179631189131080be859eefb.zip gdb-a4819f54c0006554179631189131080be859eefb.tar.gz gdb-a4819f54c0006554179631189131080be859eefb.tar.bz2 |
Treat common symbol as undefined for --no-define-common
When --no-define-common is used to build shared library, treat common
symbol as undefined so that common symbols that are referenced from a
shared library to be assigned addresses only in the main program. This
eliminates the unused duplicate space in the shared library, and also
prevents any possible confusion over resolving to the wrong duplicate
when there are many dynamic modules with specialized search paths for
runtime symbol resolution.
--no-define-common is only allowed when building a shared library.
bfd/
PR ld/21903:
* elflink.c (elf_link_add_object_symbols): Treat common symbol
as undefined for --no-define-common.
include/
PR ld/21903:
* bfdlink.h (bfd_link_info): Add inhibit_common_definition.
ld/
PR ld/21903:
* ld.h (command_line): Remove inhibit_common_definition.
* ldgram.y: Replace command_line.inhibit_common_definition with
link_info.inhibit_common_definition.
* ldlang.c (lang_common): Likewise.
* lexsup.c (parse_args): Likewise.
* ldmain.c (main): Only allow --no-define-common with -shared.
* testsuite/ld-elf/pr21903.s: New file.
* testsuite/ld-elf/pr21903a.d: Likewise.
* testsuite/ld-elf/pr21903b.d: Likewise.
* testsuite/ld-elf/pr21903c.d: Likewise.
* testsuite/ld-elf/pr21903d.d: Likewise.
* testsuite/ld-elf/pr21903e.d: Likewise.
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-elf/pr21903.s | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21903a.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21903b.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21903c.d | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21903d.d | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr21903e.d | 3 |
6 files changed, 41 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/pr21903.s b/ld/testsuite/ld-elf/pr21903.s new file mode 100644 index 0000000..9dbf96c --- /dev/null +++ b/ld/testsuite/ld-elf/pr21903.s @@ -0,0 +1,15 @@ + .text + .global start /* Used by SH targets. */ +start: + .global _start +_start: + .global __start +__start: + .global main /* Used by HPPA targets. */ +main: + .dc.a foo + .ifdef HPUX +foo .comm 4 + .else + .comm foo, 4, 4 + .endif diff --git a/ld/testsuite/ld-elf/pr21903a.d b/ld/testsuite/ld-elf/pr21903a.d new file mode 100644 index 0000000..020c561 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21903a.d @@ -0,0 +1,8 @@ +#source: pr21903.s +#ld: -shared --no-define-common +#readelf: --dyn-syms +#target: *-*-linux* *-*-gnu* + +#... +.*: 0+0 +0 +OBJECT +GLOBAL +DEFAULT +UND foo +#pass diff --git a/ld/testsuite/ld-elf/pr21903b.d b/ld/testsuite/ld-elf/pr21903b.d new file mode 100644 index 0000000..decd4f3 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21903b.d @@ -0,0 +1,8 @@ +#source: pr21903.s +#ld: -shared +#readelf: --dyn-syms +#target: *-*-linux* *-*-gnu* + +#... +.*: [0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[0-9]+ foo +#pass diff --git a/ld/testsuite/ld-elf/pr21903c.d b/ld/testsuite/ld-elf/pr21903c.d new file mode 100644 index 0000000..d3910ec --- /dev/null +++ b/ld/testsuite/ld-elf/pr21903c.d @@ -0,0 +1,3 @@ +#source: pr21903.s +#ld: --no-define-common +#error: --no-define-common may not be used without -shared diff --git a/ld/testsuite/ld-elf/pr21903d.d b/ld/testsuite/ld-elf/pr21903d.d new file mode 100644 index 0000000..ec72900 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21903d.d @@ -0,0 +1,4 @@ +#source: pr21903.s +#ld: --no-define-common -pie +#target: *-*-linux* *-*-gnu* +#error: --no-define-common may not be used without -shared diff --git a/ld/testsuite/ld-elf/pr21903e.d b/ld/testsuite/ld-elf/pr21903e.d new file mode 100644 index 0000000..894c595 --- /dev/null +++ b/ld/testsuite/ld-elf/pr21903e.d @@ -0,0 +1,3 @@ +#source: pr21903.s +#ld: -r --no-define-common +#error: --no-define-common may not be used without -shared |