-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generating multiple CUs in a single pass with libdwarfp #202
Comments
As you have already guessed I had not considered the idea of creating multiple compile units It was originally for an SGI compiler that only emitted one CU per compile. I will take a look at this, but likely not today (sorry). |
Another way to patch this would probably be a relocation, and in fact there's one emitted by
The first four come from the first CU, the rest from the second CU. I have just incremented the offset by the size of the first debug_info section. |
You are thinking along the right lines. It is a relocation issue. Anyway, the relocations are done in dwarf_pro_section.c via The section names refer to the symbol table and the value of the symtab entry For a single CU, yes the section symbol is enough. You are pushing beyond Seems like you already have the idea, I doubt if this helps at all. |
Maybe I'm missing something. The three relocations into the string table are from strp attributes. I'm using symbolic relocations because I need to patch the offsets. Shouldn't the relocations be of the form At least this is what I get if I compile something with gcc. To clarify, I'm actually using libbfd to emit the final ELF file. It wants an array of relocations which I construct with the information in the relocation data struct. I give it the section symbol and offset but it also wants that addend which I have no idea where to get from. |
Since libdwarfp generates Entries of type _Rel store an implicit addend in the location to be modified. You could adopt the _Rela approach by always initially inserting 0 in the location to be modified, |
Ah that clarifies things! I wasn't aware of how .rel works. Hm. So I need to read at the offset and take the value that has been written there and use it as the addend? EDIT: That seems to have worked, thanks a lot! |
Another thing I have noticed, which is related to emitting multiple CUs is that the data for the |
Well, it's doing more than it was designed to do! If one emits just one CU adding to .debug_str deduplicates, but My only real use of libdwarfp is with dwarfgen and I've built options to dwarfgen to tell it to dwarfgen reads in DWARF from an object, It was actually used with SGI compilers emitting DWARF2 (and not 100% of DWARF2!) |
Small update, it seems like line numbers also need some work. They stay the same between CUs and I can't seem to reset them. |
I think a really simple way of allowing this would be having a way to reset all internal state back to the original values. It wouldn't fix the string table but at least I wouldn't get weird offsets for the rest of the run. |
Don't understand enough about what your are doing to comment further or |
Even if I implemented the output as multiple CUs I have no idea if the result |
I'm currently experimenting with merging two object files, they do have multiple CUs. I imagine that tools based on this library would sometimes need to write multiple CUs consecutively, even if done with multiple files. In fact I think for my project specifically I only need one CU per file, but I do want to do this multiple times. EDIT: If it helps you I have the code for it here: https://github.com/Princess-org/Princess/blob/incremental/merge.pr |
I changed the title to reflect the actual topic of the issue: libdwarfp. |
I'm trying to use libdwarfp to generate debug information for my compiler project.
The output is used to create an ELF object file. Now, I do have multiple compilation units which all end up in a single file. This seems to work fine for the most part by calling
dwarf_producer_init
for every compilation unit and dealing with the data accordingly.Now the problem I ran into was that in the dwarf header for a compilation unit there's an offset into the abbrev section. Having 0 here works just fine for the first CU but when I add multiple ones (simply concatinating the sections) it doesn't yield the correct result.
I could probably patch the debug_info section as a workaround but maybe it would be a good idea to add a way of specifying the right offset with the api.
The text was updated successfully, but these errors were encountered: