[PATCH] D109804: [LLD] Add emission of an optional linkmap section

ben via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 14 19:42:26 PDT 2021


bd1976llvm created this revision.
Herald added subscribers: dang, rupprecht, hiraditya, arichardson, emaste.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
bd1976llvm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This adds the emission of an optional section, .debug_lld_linkmap, to the output:

The .debug_lld_linkmap section contains a list of entries that describe how the linker has mapped input sections to address regions.

The section starts with a header consisting of two fields:

length (uleb)

- The length in bytes of the linkmap data not including the length field itself. This allows for padding to be added to the section, useful for purposes such as slop for incremental linking. The value cannot exceed Elf_Off.

version (uleb)

- The version of this description information. Currently, 0. The value cannot exceed Elf_Word.

The header is followed by a single field:

entries (uleb)

- The number of entries in this section. This allows for pre-allocating an array of entry structures. The value cannot exceed Elf_Off.

Which is then followed by a list of entries. Each entry describes a section from an input file and its location in the runtime memory image of the output. Entries are composed of 4 ulebs:

- The first uleb gives an offset into the .debug_lld_linkmap_str section. The associated string contains the path of an object file that was a linker input. The value cannot exceed Elf_Off.

- The second uleb gives an offset into the .debug_lld_linkmap_str section. The associated string contains the name of an ELF section from the file identified by the objectFile field. The value cannot exceed Elf_Off.

- The third uleb is the virtual address that the linker assigned to the section. The value cannot exceed Elf_Addr.

- The fourth uleb is the size of the section in the run-time memory image. The value cannot exceed Elf_Off.

ELF section header fields are:

Property=Value
sh_type=SHT_DEBUG_LLD_LINKMAP
sh_flags=0
sh_addr=0
sh_offset=offset of the section in the file
sh_size=section size
sh_link=index of the corresponding .debug_lld_linkmap_str section
sh_info=0
sh_addralign=1
sh_entsize=1

See corresponding RFC for motivation.


https://reviews.llvm.org/D109804

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/OutputSections.cpp
  lld/ELF/SyntheticSections.cpp
  lld/ELF/SyntheticSections.h
  lld/ELF/Writer.cpp
  lld/test/ELF/debug_lld_linkmap.s
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/lib/Object/ELF.cpp
  llvm/tools/llvm-readobj/ELFDumper.cpp
  llvm/tools/llvm-readobj/ObjDumper.h
  llvm/tools/llvm-readobj/Opts.td
  llvm/tools/llvm-readobj/llvm-readobj.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109804.372619.patch
Type: text/x-patch
Size: 19758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210915/6f428787/attachment.bin>


More information about the llvm-commits mailing list