[all-commits] [llvm/llvm-project] 2b1e32: [ELF] Change common diagnostics to report both obj...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Oct 28 09:38:58 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2b1e32410c5234b6245b94a99c25047c0fbf4f13
      https://github.com/llvm/llvm-project/commit/2b1e32410c5234b6245b94a99c25047c0fbf4f13
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-10-28 (Thu, 28 Oct 2021)

  Changed paths:
    M lld/ELF/Arch/ARM.cpp
    M lld/ELF/InputSection.cpp
    M lld/ELF/Relocations.cpp
    M lld/ELF/Target.cpp
    M lld/ELF/Target.h
    M lld/test/ELF/arm-thumb-interwork-notfunc.s
    M lld/test/ELF/ppc64-error-toc-local-call.s
    M lld/test/ELF/x86-64-reloc-error2.s
    M lld/test/ELF/x86-64-reloc-range-debug-loc.s

  Log Message:
  -----------
  [ELF] Change common diagnostics to report both object file location and source file location

Many diagnostics use `getErrorPlace` or `getErrorLocation` to report a location.
In the presence of line table debug information, `getErrorPlace` uses a source
file location and ignores the object file location. However, the object file
location is sometimes more useful.

This patch changes "undefined symbol" and "out of range" diagnostics to report
both object/source file locations. Other diagnostics can use similar format if
needed.

The key idea is to let `InputSectionBase::getLocation` report the object file
location and use `getSrcMsg` for source file/line information. `getSrcMsg`
doesn't leverage `STT_FILE` information yet, but I think the temporary lack of
the functionality is ok.

For the ARM "branch and link relocation" diagnostic, I arbitrarily place the
source file location at the end of the line. The diagnostic is not very common
so its formatting doesn't need to be pretty.

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




More information about the All-commits mailing list