This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Display some optimisations when --traditional-format


How do you all feel about disabling string merging when ld is given
--traditional-format?  I think it's a reasonable addition to the
option's effect, currently it disables .stab and .eh_frame
optimisation.

The reason I'm proposing this is that I was investigating Fedora
powerpc64 binutils testsuite failures, most of which were LTO tests
that just need to be tweaked to accept "D" as well as "T" for
powerpc64 function symbols.  The other slightly more interesting
failures were the S-record tests.  They were failing because .opd
optimisation doesn't happen when ld produces srec output.  Easily
fixed by adding -no-opd-optimize to the test flags, and then the tests
pass.  However, I looked again at linker map output differences for
normal ELF output vs. srec output, and saw

@@ -112,11 +108,10 @@
                 0x00000000000010dc                PROVIDE (_etext, .)
                 0x00000000000010dc                PROVIDE (etext, .)
 
-.rodata         0x00000000000010e0       0x18
+.rodata         0x00000000000010e0       0x17
  *(.rodata .rodata.* .gnu.linkonce.r.*)
  .rodata.str1.8
-                0x00000000000010e0       0x18 tmpdir/sr1.o
-                                         0x17 (size before relaxing)
+                0x00000000000010e0       0x17 tmpdir/sr1.o
 
 .rodata1
  *(.rodata1)

Oddly, with string merge enabled .rodata size increased!  A
peculiarity of the way string merging works with aligned data like
.rodata.str1.8 in sr1.o.  We could fix the alignment padding, I
suppose, but it doesn't seem worth the effort.

So I'm committing the following, minus the ldlang.c patch to give
people time to object to that particular change.

ld/
	* ldlang.c (lang_process): Disable string merging when
	--traditional-format.
	* ldlex.h (enum option_values): Move from..
	* lexsup.c: ..here.
	* emultempl/ppc32elf.em: Include ldlex.h.
	(PARSE_AND_LIST_ARGS_CASES): Disable optimisations when
	--traditional-format.
	* emultempl/ppc64elf.em: Likewise.
ld/testsuite/
	* ld-srec/srec.exp: Remove powerpc64 flag setting.

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.390
diff -u -p -r1.390 ldlang.c
--- ld/ldlang.c	14 May 2012 19:45:28 -0000	1.390
+++ ld/ldlang.c	26 May 2012 05:58:07 -0000
@@ -6641,7 +6641,8 @@ lang_process (void)
 	 sections, so that GCed sections are not merged, but before
 	 assigning dynamic symbols, since removing whole input sections
 	 is hard then.  */
-      bfd_merge_sections (link_info.output_bfd, &link_info);
+      if (!link_info.traditional_format)
+	bfd_merge_sections (link_info.output_bfd, &link_info);
 
       /* Look for a text section and set the readonly attribute in it.  */
       found = bfd_get_section_by_name (link_info.output_bfd, ".text");
Index: ld/ldlex.h
===================================================================
RCS file: /cvs/src/src/ld/ldlex.h,v
retrieving revision 1.10
diff -u -p -r1.10 ldlex.h
--- ld/ldlex.h	8 Mar 2012 05:29:33 -0000	1.10
+++ ld/ldlex.h	26 May 2012 05:58:08 -0000
@@ -24,6 +24,119 @@
 
 #include <stdio.h>
 
+/* Codes used for the long options with no short synonyms.  150 isn't
+   special; it's just an arbitrary non-ASCII char value.  */
+enum option_values
+{
+  OPTION_ASSERT = 150,
+  OPTION_CALL_SHARED,
+  OPTION_CREF,
+  OPTION_DEFSYM,
+  OPTION_DEMANGLE,
+  OPTION_DYNAMIC_LINKER,
+  OPTION_SYSROOT,
+  OPTION_EB,
+  OPTION_EL,
+  OPTION_EMBEDDED_RELOCS,
+  OPTION_EXPORT_DYNAMIC,
+  OPTION_NO_EXPORT_DYNAMIC,
+  OPTION_HELP,
+  OPTION_IGNORE,
+  OPTION_MAP,
+  OPTION_NO_DEMANGLE,
+  OPTION_NO_KEEP_MEMORY,
+  OPTION_NO_WARN_MISMATCH,
+  OPTION_NO_WARN_SEARCH_MISMATCH,
+  OPTION_NOINHIBIT_EXEC,
+  OPTION_NON_SHARED,
+  OPTION_NO_WHOLE_ARCHIVE,
+  OPTION_OFORMAT,
+  OPTION_RELAX,
+  OPTION_NO_RELAX,
+  OPTION_RETAIN_SYMBOLS_FILE,
+  OPTION_RPATH,
+  OPTION_RPATH_LINK,
+  OPTION_SHARED,
+  OPTION_SONAME,
+  OPTION_SORT_COMMON,
+  OPTION_SORT_SECTION,
+  OPTION_STATS,
+  OPTION_SYMBOLIC,
+  OPTION_SYMBOLIC_FUNCTIONS,
+  OPTION_TASK_LINK,
+  OPTION_TBSS,
+  OPTION_TDATA,
+  OPTION_TTEXT,
+  OPTION_TTEXT_SEGMENT,
+  OPTION_TRADITIONAL_FORMAT,
+  OPTION_UR,
+  OPTION_VERBOSE,
+  OPTION_VERSION,
+  OPTION_VERSION_SCRIPT,
+  OPTION_VERSION_EXPORTS_SECTION,
+  OPTION_DYNAMIC_LIST,
+  OPTION_DYNAMIC_LIST_CPP_NEW,
+  OPTION_DYNAMIC_LIST_CPP_TYPEINFO,
+  OPTION_DYNAMIC_LIST_DATA,
+  OPTION_WARN_COMMON,
+  OPTION_WARN_CONSTRUCTORS,
+  OPTION_WARN_FATAL,
+  OPTION_NO_WARN_FATAL,
+  OPTION_WARN_MULTIPLE_GP,
+  OPTION_WARN_ONCE,
+  OPTION_WARN_SECTION_ALIGN,
+  OPTION_SPLIT_BY_RELOC,
+  OPTION_SPLIT_BY_FILE ,
+  OPTION_WHOLE_ARCHIVE,
+  OPTION_ADD_DT_NEEDED_FOR_DYNAMIC,
+  OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC,
+  OPTION_ADD_DT_NEEDED_FOR_REGULAR,
+  OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR,
+  OPTION_WRAP,
+  OPTION_FORCE_EXE_SUFFIX,
+  OPTION_GC_SECTIONS,
+  OPTION_NO_GC_SECTIONS,
+  OPTION_PRINT_GC_SECTIONS,
+  OPTION_NO_PRINT_GC_SECTIONS,
+  OPTION_HASH_SIZE,
+  OPTION_CHECK_SECTIONS,
+  OPTION_NO_CHECK_SECTIONS,
+  OPTION_NO_UNDEFINED,
+  OPTION_INIT,
+  OPTION_FINI,
+  OPTION_SECTION_START,
+  OPTION_UNIQUE,
+  OPTION_TARGET_HELP,
+  OPTION_ALLOW_SHLIB_UNDEFINED,
+  OPTION_NO_ALLOW_SHLIB_UNDEFINED,
+  OPTION_ALLOW_MULTIPLE_DEFINITION,
+  OPTION_NO_UNDEFINED_VERSION,
+  OPTION_DEFAULT_SYMVER,
+  OPTION_DEFAULT_IMPORTED_SYMVER,
+  OPTION_DISCARD_NONE,
+  OPTION_SPARE_DYNAMIC_TAGS,
+  OPTION_NO_DEFINE_COMMON,
+  OPTION_NOSTDLIB,
+  OPTION_NO_OMAGIC,
+  OPTION_STRIP_DISCARDED,
+  OPTION_NO_STRIP_DISCARDED,
+  OPTION_ACCEPT_UNKNOWN_INPUT_ARCH,
+  OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH,
+  OPTION_PIE,
+  OPTION_UNRESOLVED_SYMBOLS,
+  OPTION_WARN_UNRESOLVED_SYMBOLS,
+  OPTION_ERROR_UNRESOLVED_SYMBOLS,
+  OPTION_WARN_SHARED_TEXTREL,
+  OPTION_WARN_ALTERNATE_EM,
+  OPTION_REDUCE_MEMORY_OVERHEADS,
+#ifdef ENABLE_PLUGINS
+  OPTION_PLUGIN,
+  OPTION_PLUGIN_OPT,
+#endif /* ENABLE_PLUGINS */
+  OPTION_DEFAULT_SCRIPT,
+  OPTION_PRINT_OUTPUT_FORMAT,
+};
+
 /* The initial parser states.  */
 typedef enum input_enum {
   input_selected,		/* We've set the initial state.  */
Index: ld/lexsup.c
===================================================================
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.131
diff -u -p -r1.131 lexsup.c
--- ld/lexsup.c	26 Mar 2012 13:05:16 -0000	1.131
+++ ld/lexsup.c	26 May 2012 05:58:08 -0000
@@ -62,119 +62,6 @@ static void set_section_start (char *, c
 static void set_segment_start (const char *, char *);
 static void help (void);
 
-/* Codes used for the long options with no short synonyms.  150 isn't
-   special; it's just an arbitrary non-ASCII char value.  */
-enum option_values
-{
-  OPTION_ASSERT = 150,
-  OPTION_CALL_SHARED,
-  OPTION_CREF,
-  OPTION_DEFSYM,
-  OPTION_DEMANGLE,
-  OPTION_DYNAMIC_LINKER,
-  OPTION_SYSROOT,
-  OPTION_EB,
-  OPTION_EL,
-  OPTION_EMBEDDED_RELOCS,
-  OPTION_EXPORT_DYNAMIC,
-  OPTION_NO_EXPORT_DYNAMIC,
-  OPTION_HELP,
-  OPTION_IGNORE,
-  OPTION_MAP,
-  OPTION_NO_DEMANGLE,
-  OPTION_NO_KEEP_MEMORY,
-  OPTION_NO_WARN_MISMATCH,
-  OPTION_NO_WARN_SEARCH_MISMATCH,
-  OPTION_NOINHIBIT_EXEC,
-  OPTION_NON_SHARED,
-  OPTION_NO_WHOLE_ARCHIVE,
-  OPTION_OFORMAT,
-  OPTION_RELAX,
-  OPTION_NO_RELAX,
-  OPTION_RETAIN_SYMBOLS_FILE,
-  OPTION_RPATH,
-  OPTION_RPATH_LINK,
-  OPTION_SHARED,
-  OPTION_SONAME,
-  OPTION_SORT_COMMON,
-  OPTION_SORT_SECTION,
-  OPTION_STATS,
-  OPTION_SYMBOLIC,
-  OPTION_SYMBOLIC_FUNCTIONS,
-  OPTION_TASK_LINK,
-  OPTION_TBSS,
-  OPTION_TDATA,
-  OPTION_TTEXT,
-  OPTION_TTEXT_SEGMENT,
-  OPTION_TRADITIONAL_FORMAT,
-  OPTION_UR,
-  OPTION_VERBOSE,
-  OPTION_VERSION,
-  OPTION_VERSION_SCRIPT,
-  OPTION_VERSION_EXPORTS_SECTION,
-  OPTION_DYNAMIC_LIST,
-  OPTION_DYNAMIC_LIST_CPP_NEW,
-  OPTION_DYNAMIC_LIST_CPP_TYPEINFO,
-  OPTION_DYNAMIC_LIST_DATA,
-  OPTION_WARN_COMMON,
-  OPTION_WARN_CONSTRUCTORS,
-  OPTION_WARN_FATAL,
-  OPTION_NO_WARN_FATAL,
-  OPTION_WARN_MULTIPLE_GP,
-  OPTION_WARN_ONCE,
-  OPTION_WARN_SECTION_ALIGN,
-  OPTION_SPLIT_BY_RELOC,
-  OPTION_SPLIT_BY_FILE ,
-  OPTION_WHOLE_ARCHIVE,
-  OPTION_ADD_DT_NEEDED_FOR_DYNAMIC,
-  OPTION_NO_ADD_DT_NEEDED_FOR_DYNAMIC,
-  OPTION_ADD_DT_NEEDED_FOR_REGULAR,
-  OPTION_NO_ADD_DT_NEEDED_FOR_REGULAR,
-  OPTION_WRAP,
-  OPTION_FORCE_EXE_SUFFIX,
-  OPTION_GC_SECTIONS,
-  OPTION_NO_GC_SECTIONS,
-  OPTION_PRINT_GC_SECTIONS,
-  OPTION_NO_PRINT_GC_SECTIONS,
-  OPTION_HASH_SIZE,
-  OPTION_CHECK_SECTIONS,
-  OPTION_NO_CHECK_SECTIONS,
-  OPTION_NO_UNDEFINED,
-  OPTION_INIT,
-  OPTION_FINI,
-  OPTION_SECTION_START,
-  OPTION_UNIQUE,
-  OPTION_TARGET_HELP,
-  OPTION_ALLOW_SHLIB_UNDEFINED,
-  OPTION_NO_ALLOW_SHLIB_UNDEFINED,
-  OPTION_ALLOW_MULTIPLE_DEFINITION,
-  OPTION_NO_UNDEFINED_VERSION,
-  OPTION_DEFAULT_SYMVER,
-  OPTION_DEFAULT_IMPORTED_SYMVER,
-  OPTION_DISCARD_NONE,
-  OPTION_SPARE_DYNAMIC_TAGS,
-  OPTION_NO_DEFINE_COMMON,
-  OPTION_NOSTDLIB,
-  OPTION_NO_OMAGIC,
-  OPTION_STRIP_DISCARDED,
-  OPTION_NO_STRIP_DISCARDED,
-  OPTION_ACCEPT_UNKNOWN_INPUT_ARCH,
-  OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH,
-  OPTION_PIE,
-  OPTION_UNRESOLVED_SYMBOLS,
-  OPTION_WARN_UNRESOLVED_SYMBOLS,
-  OPTION_ERROR_UNRESOLVED_SYMBOLS,
-  OPTION_WARN_SHARED_TEXTREL,
-  OPTION_WARN_ALTERNATE_EM,
-  OPTION_REDUCE_MEMORY_OVERHEADS,
-#ifdef ENABLE_PLUGINS
-  OPTION_PLUGIN,
-  OPTION_PLUGIN_OPT,
-#endif /* ENABLE_PLUGINS */
-  OPTION_DEFAULT_SCRIPT,
-  OPTION_PRINT_OUTPUT_FORMAT,
-};
-
 /* The long options.  This structure is used for both the option
    parsing and the help text.  */
 
Index: ld/emultempl/ppc32elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc32elf.em,v
retrieving revision 1.26
diff -u -p -r1.26 ppc32elf.em
--- ld/emultempl/ppc32elf.em	26 Jul 2011 01:57:18 -0000	1.26
+++ ld/emultempl/ppc32elf.em	26 May 2012 05:58:08 -0000
@@ -27,6 +27,7 @@ fragment <<EOF
 
 #include "libbfd.h"
 #include "elf32-ppc.h"
+#include "ldlex.h"
 
 #define is_ppc_elf(bfd) \
   (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
@@ -237,6 +238,11 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LI
     case OPTION_OLD_GOT:
       old_got = 1;
       break;
+
+    case OPTION_TRADITIONAL_FORMAT:
+      notlsopt = 1;
+      no_tls_get_addr_opt = 1;
+      return FALSE;
 '
 
 # Put these extra ppc32elf routines in ld_${EMULATION_NAME}_emulation
Index: ld/emultempl/ppc64elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc64elf.em,v
retrieving revision 1.83
diff -u -p -r1.83 ppc64elf.em
--- ld/emultempl/ppc64elf.em	14 May 2012 19:45:28 -0000	1.83
+++ ld/emultempl/ppc64elf.em	26 May 2012 05:58:08 -0000
@@ -29,6 +29,7 @@ fragment <<EOF
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf64-ppc.h"
+#include "ldlex.h"
 
 /* Fake input file for stubs.  */
 static lang_input_statement_type *stub_file;
@@ -850,6 +851,16 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LI
     case OPTION_NON_OVERLAPPING_OPD:
       non_overlapping_opd = 1;
       break;
+
+    case OPTION_TRADITIONAL_FORMAT:
+      no_tls_opt = 1;
+      no_tls_get_addr_opt = 1;
+      no_opd_opt = 1;
+      no_toc_opt = 1;
+      no_multi_toc = 1;
+      no_toc_sort = 1;
+      plt_static_chain = 1;
+      return FALSE;
 '
 
 # Put these extra ppc64elf routines in ld_${EMULATION_NAME}_emulation
Index: ld/testsuite/ld-srec/srec.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-srec/srec.exp,v
retrieving revision 1.38
diff -u -p -r1.38 srec.exp
--- ld/testsuite/ld-srec/srec.exp	15 May 2012 12:55:48 -0000	1.38
+++ ld/testsuite/ld-srec/srec.exp	26 May 2012 05:58:10 -0000
@@ -266,10 +266,6 @@ proc run_srec_test { test objs } {
 	set flags "$flags -no-relax"
     }
 
-    if [istarget powerpc64*-*-*] {
-	set flags "$flags --no-toc-optimize"
-    }
-
     # Epiphany needs some help too
     if [istarget epiphany*-*-*] {
 	set flags "$flags --defsym _start=00000060"

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]