[PATCH] D79229: [llvm-objcopy] -O binary: skip empty sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 23:55:42 PDT 2020


MaskRay created this revision.
MaskRay added reviewers: grimar, jhenderson, psmith.
Herald added subscribers: llvm-commits, abrachet, kristof.beyls, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added a project: LLVM.

After SHF_ALLOC sections are ordered by LMA:

- If initial sections are empty, GNU objcopy skips their contents while we emit leading zeros. (binary-paddr.test %t4)
- If trailing sections are empty, GNU objcopy skips their contents while we emit trailing zeros. (binary-paddr.test %t5)

This patch matches GNU objcopy's behavior. In particular, the arm Linux
kernel's multi_v5_defconfig depends on this behavior:
in `vmlinux`, an empty .text_itcm is mapped at a very high address (0xfffe0000) but
the kernel does not expect `objcopy -O binary` to create a very large
`arch/arm/boot/Image` (0xfffe0000-0xc0000000 ~= 1GiB).
See https://bugs.llvm.org/show_bug.cgi?id=45632


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79229

Files:
  llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test
  llvm/tools/llvm-objcopy/ELF/Object.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79229.261434.patch
Type: text/x-patch
Size: 5059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200501/ba601894/attachment-0001.bin>


More information about the llvm-commits mailing list