[PATCH] D80859: [lld-macho] Ensure __bss sections we output have file offset of zero

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 29 22:18:33 PDT 2020


int3 created this revision.
int3 added reviewers: ruiu, pcc, MaskRay, smeenai, alexshap, gkm, Ktwu, christylee.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
int3 edited the summary of this revision.

I'm not sure it's strictly necessary, but it's what ld64 does. Moreover, the
previous implementation was buggy: llvm-mc emits `__bss` sections with an offset
of zero, but we weren't expecting that in our input, so we were copying non-zero
data from the start of the file and putting it in `__bss`, with obviously
undesirable runtime results.

I debated on whether to make a special ZeroFillSection -- separate from a
regular InputSection -- but it seemed like too much work for now. But I'm happy
to refactor if anyone feels strongly about having it as a separate class.

Depends on D80857 <https://reviews.llvm.org/D80857>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80859

Files:
  lld/MachO/InputFiles.cpp
  lld/MachO/InputSection.cpp
  lld/MachO/InputSection.h
  lld/MachO/Writer.cpp
  lld/test/MachO/bss.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80859.267433.patch
Type: text/x-patch
Size: 3428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200530/f12b7556/attachment.bin>


More information about the llvm-commits mailing list