Coder Social home page Coder Social logo

Comments (2)

ianlancetaylor avatar ianlancetaylor commented on June 30, 2024

libbacktrace only works with a fully linked executable. Are you saying that clang generates an executable with a .rel.debug_info section? Is there any spec for that?

from libbacktrace.

jmberg avatar jmberg commented on June 30, 2024

Yes, you're right, and I think we even had this discussion before. I've been using libbacktrace to extract debug data (like function prototypes) from object/archive files on disk - it's much faster than all the other alternative libraries I've looked at. I guess I'll close this.

But yes, to answer your questions: clang generates an executable with a .rel.debug_info section, specifically for strp entries. So when you normally have a strp entry with an offset into the .debug_str section (like a filename, function name, etc.) the actual offset into the .debug_str section isn't emitted directly into the .debug_info section, but as 0 instead there, with a relocation entry in the .rel.debug_info section that fixes it up.

I'm not sure there is or even has to be a spec for this, I suppose it'd be covered by the normal ELF relocation spec, just applied to the .debug_info section?

Now, overall, I don't really see any good reason for this - these entries aren't dynamic, they're just offsets into the string section, and I doubt clang gains anything by emitting things in this way. It makes the binary bigger by the .rel.debug_info section too. It could be that it does this because it emits the .debug_info section before the .debug_str section or so, but I can't really think of any fundamental reason for doing so - could build/emit them at around the same time and still dedup strings.

Interestingly I found that "objdump" is able to parse this, whereas "readelf" also doesn't expect this type of thing.

from libbacktrace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.