+2017-06-13 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ldlang.c (lang_set_startof): Skip if config.build_constructors
+ is FALSE.
+ * testsuite/ld-elf/sizeofc.d: New file.
+ * testsuite/ld-elf/startofc.d: Likewise.
+
2017-06-13 H.J. Lu <hongjiu.lu@intel.com>
* testsuite/ld-elf/sizeof.d: Renamed to ...
{
asection *s;
char leading_char;
- bfd_boolean is_elf = (bfd_get_flavour (link_info.output_bfd)
- == bfd_target_elf_flavour);
- bfd_boolean is_elocatable = bfd_link_relocatable (&link_info);
+ bfd_boolean is_elf;
+ bfd_boolean is_relocatable;
+
+ if (!config.build_constructors)
+ return;
+
+ is_elf = (bfd_get_flavour (link_info.output_bfd)
+ == bfd_target_elf_flavour);
+ is_relocatable = bfd_link_relocatable (&link_info);
leading_char = bfd_get_symbol_leading_char (link_info.output_bfd);
secname = bfd_get_section_name (link_info.output_bfd, s);
buf = (char *) xmalloc (10 + strlen (secname));
- if (!is_elocatable)
+ if (!is_relocatable)
{
sprintf (buf, ".startof.%s", secname);
h = bfd_link_hash_lookup (link_info.hash, buf, FALSE, FALSE,
--- /dev/null
+#source: sizeof.s
+#ld: -r
+#readelf: -sW
+
+Symbol table '\.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +__stop_scnfoo
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +.sizeof.scnfoo
+#pass
--- /dev/null
+#source: startof.s
+#ld: -r
+#readelf: -sW
+
+Symbol table '\.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +.startof.scnfoo
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +__start_scnfoo
+#pass