llvm-project/llvm/test/tools
Fangrui Song aa1f2c50a8 [llvm-objcopy] Simplify SHT_NOBITS -> SHT_PROGBITS promotion
GNU objcopy uses bfd_elf_get_default_section_type to decide the candidate section type,
which roughly translates to our [a] (I assume SEC_COMMON implies SHF_ALLOC):

  (!(Sec.Flags & ELF::SHF_ALLOC) || Flags & (SectionFlag::SecContents | SectionFlag::SecLoad)))

Then, it updates the section type in bfd/elf.c:elf_fake_sections if:

  if (this_hdr->sh_type == SHT_NULL)
    this_hdr->sh_type = sh_type; // common case
  else if (this_hdr->sh_type == SHT_NOBITS
           && sh_type == SHT_PROGBITS
           && (asect->flags & SEC_ALLOC) != 0)  // uncommon case
    ...
    this_hdr->sh_type = sh_type;

If the following condition is met the uncommon branch is executed:

  if (elf_section_type (osec) == SHT_NULL
      && (osec->flags == isec->flags
	  || (final_link
	      && ((osec->flags ^ isec->flags)
		  & ~(SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_RELOC)) == 0)))

I suggest we just ignore this clause and follow the common case
behavior, which is done in this patch. Rationales to do so:

If --set-section-flags is a no-op (osec->flags == isec->flags)
(corresponds to the "readonly" test in set-section-flags.test), GNU
objcopy will require (Sec.Flags & ELF::SHF_ALLOC). [a] is essentially:

  Flags & (SectionFlag::SecContents | SectionFlag::SecLoad)

This special case is not really useful. Non-SHF_ALLOC SHT_NOBITS
sections do not make much sense and it doesn't matter if they are
SHT_NOBITS or SHT_PROGBITS.

For all other RUN lines in set-section-flags.test, the new behavior
matches GNU objcopy, i.e. this patch improves compatibility.

Differential Revision: https://reviews.llvm.org/D60189

llvm-svn: 359639
2019-05-01 00:39:31 +00:00
..
dsymutil [dsymutil] Put Swift interface files into a per-arch subdirectory. 2019-04-23 16:42:35 +00:00
gold Fix one more case of passing options with too many dashes. 2019-04-29 20:13:35 +00:00
llvm-ar [llvm-nm][llvm-readelf] Avoid single-dash -long-option in tests 2019-04-27 16:12:14 +00:00
llvm-cfi-verify [cfi-verify] Support cross-DSO 2018-08-24 15:21:58 +00:00
llvm-config [gn build] Commit change that should have been in r350410. 2019-01-04 17:26:05 +00:00
llvm-cov Speeding up llvm-cov export with multithreaded renderFiles implementation. 2019-03-14 17:49:27 +00:00
llvm-cvtres llvm-cvtres: Make new dupe resource error a bit friendlier 2019-04-24 23:26:30 +00:00
llvm-cxxdump [llvm-cxxdump] Use error reporting helpers from support 2018-11-11 01:24:02 +00:00
llvm-cxxfilt [llvm-cxxfilt]Add test to show that empty lines can be handled 2019-03-12 15:42:38 +00:00
llvm-cxxmap Add flag to llvm-profdata to allow symbols in profile data to be remapped, and 2018-09-13 20:22:02 +00:00
llvm-diff llvm-diff: Fix crash on anonymous functions 2018-09-24 04:42:13 +00:00
llvm-dlltool [llvm-dlltool] Set a proper machine type for weak symbol object files 2019-03-26 09:02:44 +00:00
llvm-dwarfdump [DWARF] Fix dump of local/foreign TU lists in .debug_names 2019-04-29 08:55:10 +00:00
llvm-dwp [llvm-dwp] Avoid writing the output dwp file when there is an error 2019-02-12 20:00:51 +00:00
llvm-elfabi [yaml2obj][obj2yaml] - Add support for dumping/parsing .dynamic sections. 2019-02-09 11:34:28 +00:00
llvm-exegesis [llvm-exegesis] Fix serialization/deserialization of special NoRegister register (PR41448) 2019-04-11 07:20:50 +00:00
llvm-extract [llvm-extract] Expose the group extraction feature of the BlockExtractor 2019-04-29 16:14:03 +00:00
llvm-isel-fuzzer
llvm-lib [llvm-ar][libObject] Fix relative paths when nesting thin archives. 2019-02-13 23:39:41 +00:00
llvm-lit
llvm-lto
llvm-lto2 [NewPM] teach -passes= to emit meaningful error messages 2018-10-17 10:36:23 +00:00
llvm-mc Replace unused output filenames with /dev/null in tests 2018-07-02 18:16:44 +00:00
llvm-mca [llvm-mca][x86] Fix MMX PMOVMSKB test 2019-04-29 18:24:30 +00:00
llvm-modextract
llvm-mt [llvm-mt] Use WithColor for printing errors. 2018-06-23 16:49:07 +00:00
llvm-nm [llvm-nm] Add --special-syms no-op flag 2019-04-30 13:51:48 +00:00
llvm-objcopy [llvm-objcopy] Simplify SHT_NOBITS -> SHT_PROGBITS promotion 2019-05-01 00:39:31 +00:00
llvm-objdump [Object][XCOFF] Add intial support for section header table. 2019-04-25 21:36:04 +00:00
llvm-opt-fuzzer [NewPM] teach -passes= to emit meaningful error messages 2018-10-17 10:36:23 +00:00
llvm-opt-report
llvm-pdbdump [NativePDB] Fix access to both old & new fpo data entries from dbi stream 2019-01-30 10:40:45 +00:00
llvm-profdata [llvm-profdata] Add overlap command to compute similarity b/w two profile files 2019-04-30 21:19:12 +00:00
llvm-rc Fix llvm-rc tests. 2019-03-27 20:15:08 +00:00
llvm-readobj [WebAssembly] Support EXPLICIT_NAME symbols in llvm-readobj 2019-04-30 19:30:24 +00:00
llvm-size [llvm-nm][llvm-size] Use --double-dash options in tests 2019-04-26 13:42:16 +00:00
llvm-split
llvm-strings [llvm-strings] Fix whitespaces to match strings output. 2018-11-09 18:03:21 +00:00
llvm-symbolizer Change \r\n -> \n for llvm-symbolizer/help.test after rL358749 2019-04-19 12:28:36 +00:00
llvm-xray/X86 [llvm-xray] Support for PIE 2018-12-14 01:37:56 +00:00
lto [llvm-nm][llvm-readelf] Avoid single-dash -long-option in tests 2019-04-27 16:12:14 +00:00
obj2yaml MinidumpYAML: Add support for ModuleList stream 2019-04-18 14:57:31 +00:00
opt-viewer [opt-viewer] Add --filter option to select remarks for displaying. 2019-02-06 18:43:37 +00:00
sancov
sanstats [yaml2obj][obj2yaml] - Change how symbol's binding is descibed when parsing/dumping. 2019-04-03 14:53:42 +00:00
yaml2obj [llvm-nm][llvm-readelf] Avoid single-dash -long-option in tests 2019-04-27 16:12:14 +00:00