+2017-08-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/21903:
+ * elflink.c (elf_link_add_object_symbols): Treat common symbol
+ as undefined for --no-define-common.
+
2017-08-05 Alan Modra <amodra@gmail.com>
* elf32-hppa.c (elf32_hppa_set_gp): Don't require an
override = FALSE;
+ /* Treat common symbol as undefined for --no-define-common. */
+ if (isym->st_shndx == SHN_COMMON
+ && info->inhibit_common_definition)
+ isym->st_shndx = SHN_UNDEF;
+
flags = BSF_NO_FLAGS;
sec = NULL;
value = isym->st_value;
+2017-08-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/21903:
+ * bfdlink.h (bfd_link_info): Add inhibit_common_definition.
+
2017-07-31 Nick Clifton <nickc@redhat.com>
PR 21850
/* TRUE if generate a 1-byte NOP as suffix for x86 call instruction. */
unsigned int call_nop_as_suffix : 1;
+ /* TRUE if common symbols should be treated as undefined. */
+ unsigned int inhibit_common_definition : 1;
+
/* The 1-byte NOP for x86 call instruction. */
char call_nop_byte;
+2017-08-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ 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.
+
2017-08-05 Alan Modra <amodra@gmail.com>
* testsuite/ld-unique/pr21529.d: Don't xfail hppa.
/* 1 => assign space to common symbols even if `relocatable_output'. */
bfd_boolean force_common_definition;
- /* 1 => do not assign addresses to common symbols. */
- bfd_boolean inhibit_common_definition;
-
/* If TRUE, build MIPS embedded PIC relocation tables in the output
file. */
bfd_boolean embedded_relocs;
| FORCE_GROUP_ALLOCATION
{ command_line.force_group_allocation = TRUE ; }
| INHIBIT_COMMON_ALLOCATION
- { command_line.inhibit_common_definition = TRUE ; }
+ { link_info.inhibit_common_definition = TRUE ; }
| INPUT '(' input_list ')'
| GROUP
{ lang_enter_group (); }
static void
lang_common (void)
{
- if (command_line.inhibit_common_definition)
+ if (link_info.inhibit_common_definition)
return;
if (bfd_link_relocatable (&link_info)
&& !command_line.force_common_definition)
if (argc == 2 && version_printed)
xexit (0);
+ if (link_info.inhibit_common_definition && !bfd_link_dll (&link_info))
+ einfo (_("%P%F: --no-define-common may not be used without -shared\n"));
+
if (!lang_has_input_file)
{
if (version_printed || command_line.print_output_format)
input_flags.dynamic = FALSE;
break;
case OPTION_NO_DEFINE_COMMON:
- command_line.inhibit_common_definition = TRUE;
+ link_info.inhibit_common_definition = TRUE;
break;
case OPTION_NO_DEMANGLE:
demangling = FALSE;
--- /dev/null
+ .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
--- /dev/null
+#source: pr21903.s
+#ld: -shared --no-define-common
+#readelf: --dyn-syms
+#target: *-*-linux* *-*-gnu*
+
+#...
+.*: 0+0 +0 +OBJECT +GLOBAL +DEFAULT +UND foo
+#pass
--- /dev/null
+#source: pr21903.s
+#ld: -shared
+#readelf: --dyn-syms
+#target: *-*-linux* *-*-gnu*
+
+#...
+.*: [0-9a-f]+ +4 +OBJECT +GLOBAL +DEFAULT +[0-9]+ foo
+#pass
--- /dev/null
+#source: pr21903.s
+#ld: --no-define-common
+#error: --no-define-common may not be used without -shared
--- /dev/null
+#source: pr21903.s
+#ld: --no-define-common -pie
+#target: *-*-linux* *-*-gnu*
+#error: --no-define-common may not be used without -shared
--- /dev/null
+#source: pr21903.s
+#ld: -r --no-define-common
+#error: --no-define-common may not be used without -shared