[all-commits] [llvm/llvm-project] b209b9: [COFF] Don't reject executables with data director...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Wed Jun 15 06:52:26 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b209b9e11c265e52f5897b2e014aa6933eb26703
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-15 (Wed, 15 Jun 2022)

  Changed paths:
    M llvm/lib/Object/COFFObjectFile.cpp
    A llvm/test/Object/Inputs/COFF/data-dir-out-of-bounds.yaml
    A llvm/test/Object/coff-data-dir-out-of-bounds.test

  Log Message:
  [COFF] Don't reject executables with data directories pointing outside of provided data

Before bb94611d6545c2c5271f5bb01de1aa4228a37250, we didn't check
that the sections in the COFF executable actually contained enough
raw data, when looking up what section contains tables pointed to
by the data directories.

That commit added checking, to avoid setting a pointer that points
out of bounds - by rejecting such executables.

It turns out that some binaries (e.g.g a "helper.exe" provided by
NSIS) contains a base relocation table data directory that points
into the wrong section. It points inside the virtual address space
allocated for that section, but the section contains much less raw
data, and the table points outside of the provided raw data.

No longer reject such binaries (to let tools operate on them and
inspect them), but don't set the table pointers (so that when
printing e.g. base relocations, we don't print anything).

This should fix the regression pointed out in

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

  Commit: aefa11166f203386017f0eff36f7392bc0c2fa23
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-15 (Wed, 15 Jun 2022)

  Changed paths:
    M lld/MinGW/Driver.cpp
    M lld/MinGW/Options.td
    M lld/test/MinGW/driver.test

  Log Message:
  [LLD] [MinGW] Implement --disable-reloc-section, mapped to /fixed

Since binutils 2.36, GNU ld defaults to emitting base relocations,
and that version added the new option --disable-reloc-section to
disable it.

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

Compare: https://github.com/llvm/llvm-project/compare/c60c13f7eb71...aefa11166f20

More information about the All-commits mailing list