2

I would like to add a start and end symbol around each debug info section so that I can access them from my program. I tried the following scheme:

.debug.info ALIGN(4K) : {
    DEBUG_INFO_START = .;
    *(.debug.info)
    DEBUG_INFO_END = .;
}
.debug.abbrev ALIGN(4K) : {
    DEBUG_ABBREV_START = .;
    *(.debug.abbrev)
    DEBUG_ABBREV_END = .;
}
/* etc. */

But that causes each section (including .text, .rodata etc.) and the resulting binary to triple in size. What could be causing this? As you can see from the dumps below, the debug info is included in both cases so that isn't what's causing the increase in size.

I'm using Zig and the LLVM toolchain.

Link to the whole link script. Link to a dump of the binary without the link script modifications, link to a dump with the modifications.

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
SamTebbs33
  • 5,507
  • 3
  • 22
  • 44
  • This isn't an answer to your question, just an inquiry. Why do you want to output the debug info to the binary? I ask because it seems like what you are doing is a possible solution to another problem you had. I'd be curious to understand the `why` on this. – Michael Petch Oct 01 '19 at 23:51
  • @MichaelPetch I would like my kernel to be able to print stack traces, so I need to know where the debug info is. My current workaround is to get grub to tell me where the elf section header was loaded, but unfortunately it seems like grub doesn't load the debug sections, just the .text, .bss etc. – SamTebbs33 Oct 02 '19 at 10:22

0 Answers0