Page MenuHomePhabricator

[RTDYLD] be more defensive about relocations with empty symbol names

Authored by vchuravy on Oct 12 2020, 7:55 AM.



I am unsure if we should add these asserts, so I am putting this up for discussions.

The impetus for this was
IIUC we map many relocations to the symbol name "". (See
and looks at GlobalSymbolTable to determine whether or not
this is an absolute relocation. If someone happens to insert a symbol that has a "" as the name, all the absolute relocations will now be treated wrong.

So my question is: We are using "" as a sentinel value for absolute relocations. Should we ensure that actually is a sentinel value, or is there a platform were "" is a valid symbol name,
and we should use a different sentinel, like the original NULL pointer?

For JuliaLang I am currently filterting out the wrong relocation, after I was unable to find the producer of it.

Diff Detail

Unit TestsFailed

3,970 mswindows > Clang-Unit.DirectoryWatcher/_/DirectoryWatcherTests_exe::DirectoryWatcherTest.AddFiles
Note: Google Test filter = DirectoryWatcherTest.AddFiles [==========] Running 1 test from 1 test case.
3,740 mswindows > Clang-Unit.DirectoryWatcher/_/DirectoryWatcherTests_exe::DirectoryWatcherTest.DeleteFile
Note: Google Test filter = DirectoryWatcherTest.DeleteFile [==========] Running 1 test from 1 test case.
3,790 mswindows > Clang-Unit.DirectoryWatcher/_/DirectoryWatcherTests_exe::DirectoryWatcherTest.ModifyFile
Note: Google Test filter = DirectoryWatcherTest.ModifyFile [==========] Running 1 test from 1 test case.

Event Timeline

vchuravy created this revision.Oct 12 2020, 7:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2020, 7:55 AM
vchuravy requested review of this revision.Oct 12 2020, 7:55 AM
vchuravy updated this revision to Diff 297590.Oct 12 2020, 7:58 AM


vtjnash added a subscriber: vtjnash.Nov 3 2020, 7:30 AM

I think these need to be handled in these places, given how clang emits relocations in .dwarf sections. For some contextual history, this was added as a sentinel for absolute symbols in (and later adjusted in If I compare readelf --relocations of clang vs. gcc, I see GCC emit a name for these symbols for x86 inside the .dwarf sections, but that clang uses the name NULL, which gets translated there into the empty string.


This is unreachable, since line 1092 already handled it (which I think is also the reason for needing the rest of this patch)

vchuravy abandoned this revision.Nov 3 2020, 2:51 PM