Page MenuHomePhabricator

Only replace object file sections when non-empty

Authored by fjricci on Mar 2 2018, 12:34 PM.



In order to allow some sections to exist either in split debug-info or in the main binary,
don't replace non-empty sections with empty sections.

Event Timeline

fjricci created this revision.Mar 2 2018, 12:34 PM
labath requested changes to this revision.Mar 2 2018, 1:01 PM

This looks like a perfect case for lldb-test. You will run into a couple of problems which will prevent this from working out of the box. I tried to fix those in, but that turned into a major refactor. Until that CL lands, we should be able to make a quick hack in lldb-test which will make this testable:
The thing you will need to modify is to explicitly call module->GetSymbolVendor() before dumping out the sections (so that the symbol vendor populates these), and avoid setting the SymbolFileSpec on the ModuleSpec (so that the symbol vendor will find the external symbol file.

This revision now requires changes to proceed.Mar 2 2018, 1:01 PM
labath added a comment.Mar 6 2018, 8:32 AM

Ok, as of r326805 it should be very easy to write a test for this. You can look at the test in that commit for inspiration.

Btw, do you happen to know why we have two copies of the section merging code? While working on that patch I noticed an issue that is caused (in part*) by the fact that we merge the sections three times. I've tried to remove the copy in ObjectFileELF, and everything seems to work fine, but our test support coverage for the debug-info-in-separate-file is not that awesome. If you have any other tests for this, I'd appreciate if you can run them before I check that in (I'll send you a patch soon).

(*) The problem is that we are replacing the sections by their IDs, but (ELF?) section IDs are unique only if they all come from a single object file. So when we start replacing them the second time round, we end up overwriting random sections. When we replace the sections only once, the code will be technically correct, but the replacement-by-id idea seems still a bit sketchy.

labath resigned from this revision.Aug 9 2019, 2:06 AM
fjricci abandoned this revision.Aug 9 2019, 4:22 AM

Didn’t realize I still had open revisions, haven’t worked on lldb in quite some time