[PATCH] D71035: [llvm-objcopy][ELF] -O binary: use LMA instead of sh_offset to decide where to write section contents

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 10:18:45 PST 2019


MaskRay updated this revision to Diff 233137.
MaskRay marked 3 inline comments as done.
MaskRay added a comment.

Fix tests.

In GNU objcopy, LMA = sh_offset-p_offset+p_paddr for a section contained in a PT_LOAD.

The rules that llvm-objcopy and GNU objcopy use to decide whether a section is contained in a PT_LOAD are different.
We use sh_offset for non-SHT_NOBITS sections, but GNU objcopy appears to use sh_addr (see readelf -l output)
So some properties (VAddr: 0x20000) can cause different behaviors, but we probably don't bother testing that because "VAddr != sh_addr of the first section" is unrealistic.

Changed the tests to have same behaviors with llvm-objcopy and GNU objcopy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71035

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: D71035.233137.patch
Type: text/x-patch
Size: 7579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191210/18bf7099/attachment.bin>


More information about the llvm-commits mailing list