[PATCH] D43819: [ELF] - Restrict section offsets that exceeds file size.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 6 15:21:45 PST 2018


ruiu added inline comments.


================
Comment at: ELF/Writer.cpp:1832
+    return "<empty range at 0x" + utohexstr(Addr) + ">";
+  return "[0x" + utohexstr(Addr) + " -> 0x" + utohexstr(Addr + Len - 1) + "]";
+}
----------------
`[start -> end]` (e.g. `[0xFFFFFFFF20000000 -> 0xFFFFFFFE40000000]`) is a weird notion to represent a range. I think `[start:end]` is more common.


================
Comment at: ELF/Writer.cpp:1906-1908
+  // It is possible to get file offset overlaps or overflows with linker
+  // scripts. We perform checks required in checkNoOverlappingSections() and
+  // want to prevent file size overflows here because it would crash the linker.
----------------
But why does this happen? If we detects all backward movements of '.', it shouldn't happen, no?


================
Comment at: test/ELF/linkerscript/sections-va-overflow.test:7
+  ph_headers  PT_PHDR PHDRS;
+  ph_text PT_LOAD FILEHDR PHDRS  FLAGS (0x1 | 0x4); 
+}
----------------
This file contains trailing white spaces.


================
Comment at: test/ELF/linkerscript/sections-va-overflow.test:9
+}
+SECTIONS { 
+ . = 0xffffffff20000000;
----------------
Please insert a blank line between PHDRS and SECTIONS because that's what you would usually do to normal linker scripts.


https://reviews.llvm.org/D43819





More information about the llvm-commits mailing list