[all-commits] [llvm/llvm-project] d28c6d: [llvm-objcopy][ELF] -O binary: use LMA instead of ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Sun Dec 15 21:47:46 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d28c6d51d1547d9cd7cd5b7e36b4c03f38ef7c67
      https://github.com/llvm/llvm-project/commit/d28c6d51d1547d9cd7cd5b7e36b4c03f38ef7c67
  Author: Fangrui Song <maskray at google.com>
  Date:   2019-12-15 (Sun, 15 Dec 2019)

  Changed paths:
    M llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test
    M llvm/tools/llvm-objcopy/ELF/Object.cpp

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

.text sh_address=0x1000 sh_offset=0x1000
.data sh_address=0x3000 sh_offset=0x2000

In an objcopy -O binary output, the distance between two sections equal
their LMA differences (0x3000-0x1000), instead of their sh_offset
differences (0x2000-0x1000). This patch changes our behavior to match
GNU.

This rule gets more complex when the containing PT_LOAD has
p_vaddr!=p_paddr. GNU objcopy essentially computes
sh_offset-p_offset+p_paddr for each candidate section, and removes the
gap before the first address.

Added tests to binary-paddr.test to catch the compatibility problem.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D71035




More information about the All-commits mailing list