Fix splitBlock so that it can handle the case when the block being
split has symbols span across the split boundary. This is an error
case in general but for EHFrame splitting on macho platforms, there is an
anonymous symbol that marks the entire block. Current implementation
will leave a symbol that is out of bound of the underlying block. Fix
the problem by dropping such symbols when the block is split.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/ExecutionEngine/JITLink/JITLink.cpp | ||
---|---|---|
216–224 | This doesn't seem safe in general, since anonymous symbols aren't necessarily safe to split just because they're anonymous. I wonder if, rather than return Errors, it'd be better to trust the caller and split blocks anyway (as the code was), but truncate Symbol::size() as necessary to avoid it going past the end of the block it points at. Two other ideas:
@lhames, WDYT? |
llvm/lib/ExecutionEngine/JITLink/JITLink.cpp | ||
---|---|---|
216–224 | So the symbol in question is the one created here: MachOLinkGraphBuilder::addSectionStartSymAndBlock I don't know how this one is being used but the one marked eh_frame will become redundant after eh_frame splitting. I guess we can shrink the size of section start sym to have size 0 then we can just always split the block and not worry about that. Then any symbols span across the split boundary will be Error. |
I wonder if, rather than return Errors, it'd be better to trust the caller and split blocks anyway (as the code was), but truncate Symbol::size() as necessary to avoid it going past the end of the block it points at.
I like this as a short-term solution.
I think this issue exposes limitations in LinkGraph's current design. I'm not sure that we need/want LLVM-style users-lists for Symbols, but if we just added a ref-count to Symbols we could have a .isUnreferenced method that would be really helpful here: Clients could choose to remove unreferenced anonymous symbols (which should always be safe, since they can be recreated easily), and/or truncate named symbols, and then splitBlock could return an Error for any remaining symbols that extend past a split point.
This doesn't seem safe in general, since anonymous symbols aren't necessarily safe to split just because they're anonymous.
I wonder if, rather than return Errors, it'd be better to trust the caller and split blocks anyway (as the code was), but truncate Symbol::size() as necessary to avoid it going past the end of the block it points at.
Two other ideas:
@lhames, WDYT?