This would have caught the invalid object file I used in my test case in
r307726. The OOB was only caught by ASan later, which is slow and
doesn't work on some platforms. LLD should do some basic input
validation itself. This check isn't perfect, so relocations can reach
OOB by up to seven bytes, but it's better than what we had and probably
cheap.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
This adds one virtual function call for each relocation. I believe it's negligible, but can you run the linker with and without this patch to see if this is fine?
lld/COFF/Chunks.cpp | ||
---|---|---|
218 ↗ | (On Diff #106467) | could hoist getSize() outside the loop? |
Comment Actions
Hm, I hadn't noticed that. We know we're dealing with a SectionChunk, so the call doesn't have to be virtual. Maybe we should mark SectionChunk final to get that benefit elsewhere.
lld/COFF/Chunks.cpp | ||
---|---|---|
218 ↗ | (On Diff #106467) | We should just do that. Even if we inlined the implementation, it's a load. |