Index: test/tools/gold/X86/multiple-data.s =================================================================== --- test/tools/gold/X86/multiple-data.s +++ test/tools/gold/X86/multiple-data.s @@ -5,6 +5,7 @@ # RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-unknown-linux-gnu # RUN: llvm-as %p/Inputs/multiple-data.ll -o %t2.o # RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ +# RUN: -plugin-opt=section-ordering \ # RUN: -m elf_x86_64 -o %t.exe %t2.o %t.o \ # RUN: --section-ordering-file=%t_order_lto.txt # RUN: llvm-readobj -elf-output-style=GNU -t %t.exe | FileCheck %s Index: test/tools/gold/X86/multiple-sections.ll =================================================================== --- test/tools/gold/X86/multiple-sections.ll +++ test/tools/gold/X86/multiple-sections.ll @@ -3,6 +3,7 @@ ; RUN: echo ".text.pat" >> %t_order_lto.txt ; RUN: llvm-as %s -o %t.o ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ +; RUN: -plugin-option=section-ordering \ ; RUN: -m elf_x86_64 -o %t.exe %t.o \ ; RUN: --section-ordering-file=%t_order_lto.txt ; RUN: llvm-readobj -elf-output-style=GNU -t %t.exe | FileCheck %s Index: tools/gold/gold-plugin.cpp =================================================================== --- tools/gold/gold-plugin.cpp +++ tools/gold/gold-plugin.cpp @@ -203,6 +203,8 @@ static std::string dwo_dir; /// Statistics output filename. static std::string stats_file; + // Section ordering. + static bool section_ordering; // Optimization remarks filename and hotness options static std::string OptRemarksFilename; @@ -278,6 +280,8 @@ OptRemarksWithHotness = true; } else if (opt.startswith("stats-file=")) { stats_file = opt.substr(strlen("stats-file=")); + } else if (opt == "section-ordering") { + section_ordering = true; } else { // Save this option to pass to the code generator. // ParseCommandLineOptions() expects argv[0] to be program name. Lazily @@ -834,9 +838,8 @@ // FIXME: Check the gold version or add a new option to enable them. Conf.Options.RelaxELFRelocations = false; - // Enable function/data sections by default. - Conf.Options.FunctionSections = true; - Conf.Options.DataSections = true; + Conf.Options.FunctionSections = options::section_ordering; + Conf.Options.DataSections = options::section_ordering; Conf.MAttrs = MAttrs; Conf.RelocModel = RelocationModel;