This teaches yaml2obj to allocate file space for a no-bits section
when there is a non-nobits section in the same segment that follows it.
It was discussed in D78005 thread and matches GNU linkers and LLD behavior.
Differential D80629
[yaml2obj] - Allocate the file space for SHT_NOBITS sections in some cases. grimar on May 27 2020, 6:16 AM. Authored by
Details This teaches yaml2obj to allocate file space for a no-bits section It was discussed in D78005 thread and matches GNU linkers and LLD behavior.
Diff Detail
Event TimelineComment Actions This behavior seems reasonable.
Matches GNU linkers and LLD. Checked with: % cat a.s .section .data,"aw" .byte 0 .section .dataa,"aw",@nobits .byte 0 .section .datab,"aw",@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 Actions
Comment Actions
Comment Actions This is causing the 32-bit ARM bots to fail test tools/obj2yaml/ELF/program-headers.yaml. It looks like an out of memory error, but it has been happening consistently for a large number of builds now, and looks related to this change. First failing build: http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/16765 Log: ******************** TEST 'LLVM :: tools/obj2yaml/ELF/program-headers.yaml' FAILED ******************** Script: -- : 'RUN: at line 5'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp1 : 'RUN: at line 9'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/llvm-readelf --segments /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp1 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=SEGMENT-MAPPING : 'RUN: at line 37'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/obj2yaml /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp1 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=YAML : 'RUN: at line 241'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj --docnum=2 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp2 : 'RUN: at line 242'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/obj2yaml /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp2 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=EMPTY : 'RUN: at line 331'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj --docnum=3 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp3 : 'RUN: at line 332'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/llvm-readelf --segments --sections /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp3 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=MISALIGNED-READELF : 'RUN: at line 333'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/obj2yaml /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp3 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=MISALIGNED-YAML : 'RUN: at line 373'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj --docnum=4 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp4 : 'RUN: at line 374'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/obj2yaml /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp4 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=NON-ALLOC : 'RUN: at line 419'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj --docnum=5 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp5 : 'RUN: at line 420'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/obj2yaml /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp5 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=NOBITS : 'RUN: at line 523'; not /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj --docnum=6 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp6 2>&1 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=UNSORTED --implicit-check-not="error:" : 'RUN: at line 579'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj --docnum=7 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp7 : 'RUN: at line 587'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/llvm-readelf -sections /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp7 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=ZERO-SIZE-MAPPING : 'RUN: at line 597'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/obj2yaml /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp7 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=ZERO-SIZE : 'RUN: at line 648'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj --docnum=8 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp8 : 'RUN: at line 649'; /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/obj2yaml /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp8 | /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/FileCheck /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml --check-prefix=BROKEN-VA -- Exit Code: 134 Command Output (stderr): -- LLVM ERROR: out of memory PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump: 0. Program arguments: /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj --docnum=5 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp5 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.script: line 18: 41905 Aborted (core dumped) /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/bin/yaml2obj --docnum=5 /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/llvm/llvm/test/tools/obj2yaml/ELF/program-headers.yaml -o /home/tcwg-buildslave/worker/clang-cmake-armv7-quick/stage1/test/tools/obj2yaml/ELF/Output/program-headers.yaml.tmp5 -- ******************** Comment Actions @ostannard, yes, sorry for the breakage. It happens because program-headers.yaml has a test that tries to produce a >4Gb object with this patch. Comment Actions
Now when we have a 10 MB limitation of the output size produced by yaml2obj, It has the following case: - Name: .bss Type: SHT_NOBITS Flags: [ SHF_WRITE, SHF_ALLOC ] ## Use a size that is larger than the file size. Size: 0x00000000FFFFFFFF With this patch we allocate the file space for it. And
Comment Actions LGTM.
|
Inlining getChunksAfter can avoid the cost constructing a vector.