[PATCH] D49383: [cfi-verify] Add an option to treat calls to a specified function as traps.

Joel Galenson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 09:31:37 PDT 2018


jgalenson created this revision.
jgalenson added reviewers: pcc, vlad.tsyrklevich.
Herald added a reviewer: javed.absar.
Herald added a subscriber: llvm-commits.

This patch adds the -trap-function argument to cfi-verify.  It allows treating calls to the specified function as traps. 
 With this, cfi-verify works when CFI is enabled in diagnostics or cross-DSO mode.

In addition to normal symbols, we also parse the dynamic relocations to handle cross-DSO calls in libraries.

I'm not very happy with the current state of this patch, so I'm uploading it to request some advice.

First, I don't like how this builds in assumptions about ELF files and PLT entries.  Ideally, I would only need the first part of parseSymbolTable (the loop over all the symbols).  However, the list of symbols does not contain PLT entries, so I need the complicated second part.  You can see this by comparing GNU objdump and LLVM objdump on a binary; the former will label PLT entries as well as calls into it with function names, while the latter will simply show that it's some offset into the PLT.  So ideally this would be done somewhere else in LLVM so that multiple other places can benefit.  However, I don't know where that would be, and I'm not an expert on ELF files, so this seemed safest for now.  But I'd appreciate advice on whether we should keep this or try to make a larger change.

Second, I don't know the best way of testing this.  I need correctly-linked files to populate the symbol table and PLT, but I don't think I can assume a linker, and llvm-mc doesn't seem to handle calls to undefined functions well.  So for now I just updated a binary with a valid PLT, but I'd much prefer to use .s and unit tests like the others.  Is there a good way to do that, or does this suffice?


Repository:
  rL LLVM

https://reviews.llvm.org/D49383

Files:
  test/tools/llvm-cfi-verify/AArch64/Inputs/call
  test/tools/llvm-cfi-verify/AArch64/call.s
  tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  tools/llvm-cfi-verify/lib/FileAnalysis.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49383.155696.patch
Type: text/x-patch
Size: 7029 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180716/33239e90/attachment.bin>


More information about the llvm-commits mailing list