[PATCH] D80629: [yaml2obj] - Allocate the file space for SHT_NOBITS sections in some cases.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 27 21:16:11 PDT 2020


MaskRay added a comment.

This behavior seems reasonable.

> It was discussed in D78005 <https://reviews.llvm.org/D78005> thread and matches GNU linkers behavior.

Matches GNU linkers and LLD. Checked with:

  % cat a.s
  .section .data,"aw"
  .byte 0
  
  .section .dataa,"aw", at nobits
  .byte 0
  
  .section .datab,"aw", at nobits
  .byte 0
  
  .section .datac,"aw"
  .byte 0
  
  % cat a.x
  SECTIONS {
    .data : { *(.data) }
    .dataa : { *(.dataa) }
    .datab : { *(.datab) }
    .datac : { *(.datac) }
    .bss : { *(.bss) }
  }
  
  % ld.lld -T a.x a.o -o a



================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:872
+  for (const ELFYAML::ProgramHeader &PH : Phdrs)
+    for (ELFYAML::Chunk *C : getChunksAfter(PH, S.Name))
+      if (isa<ELFYAML::Fill>(C) ||
----------------
Inlining getChunksAfter can avoid the cost constructing a vector.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80629/new/

https://reviews.llvm.org/D80629





More information about the llvm-commits mailing list