llvm-project
fee17e2b - [dsymutil] Don't write past a DIE for a relocation that does not fit (#247778)

Commit
3 hours ago
[dsymutil] Don't write past a DIE for a relocation that does not fit (#247778) applyValidRelocs() asserts that a relocation fits in the DIE it patches, then writes it regardless. A relocation map which does not describe the DWARF of its dSYM holds relocations running past their DIE, and one larger than 8 bytes also overflows the buffer its value is built in. Reject a relocation running past the range it is looked up in, with a warning. getRelocations() does so for every lookup: such a relocation is not applied, does not keep its DIE, and is not saved to the output relocation map. The asserts in applyValidRelocs() now hold. The check needs exact ranges. In both linkers, getVariableRelocAdjustment() passed a range starting at the length of the block, which precedes the expression. Two tests had their relocations on that length, where only such a range found them. Move them to the operand. Reject a size other than 4 or 8 bytes when loading the relocation map, as findValidRelocs() does for an object file. Co-authored-by: Alpha Abdoulaye <aabdoulaye@apple.com> Assisted-by: Claude
Author
Parents
Loading