[PATCH] D30886: [ELF] Pad x86 executable sections with 0xcc int3 instructions

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 3 06:40:54 PDT 2017


jhenderson updated this revision to Diff 93853.
jhenderson added a comment.

Thanks @ruiu. I clearly overthought the previous attempt! I've updated the diff based on your suggestions. There are a few points I feel are worth mentioning:

- I've had to add an additional check to prevent the .eh_frame_hdr section from being written if it is empty (previously its writeTo method was called, which did nothing, but now the writeTo method writes padding to fill the section). I think there's a wider issue here regarding .eh_frame_hdr, namely that writeSections unconditionally writes this section even if it is empty and has no corresponding .eh_frame section. It has previously been discarded from the main output sections list, but that is not used in this case. I think fixing this is a separate change.
- BYTE()-family commands are now ignored for the purposes of padding, and are written over the top, meaning that the padding does not start with the correct byte for these cases. This is no worse than before, but I will fix it in a separate change.
- There was no test for the case with leading padding caused by assigning to dot in the linker script. I have extended a case, to add coverage, since I am changing behaviour in the area.


https://reviews.llvm.org/D30886

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  ELF/OutputSections.cpp
  ELF/OutputSections.h
  ELF/SyntheticSections.cpp
  ELF/Target.cpp
  ELF/Target.h
  ELF/Writer.cpp
  test/ELF/default-fill.s
  test/ELF/linkerscript/excludefile.s
  test/ELF/linkerscript/fill-exec-sections.s
  test/ELF/linkerscript/fill.s
  test/ELF/linkerscript/sections-padding.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30886.93853.patch
Type: text/x-patch
Size: 13990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170403/97a6eb61/attachment.bin>


More information about the llvm-commits mailing list