[Dwarf-Discuss] Section offset values

Jakub Křoustek ikroustek at fit.vutbr.cz
Mon Oct 25 05:31:24 PDT 2010


Hi!

I have an assembler/compiler related question about "section offset"
attributes in DWARF, but I hope someone will be able to give me the answer.

When I use some well known compiler like gcc, llvm-gcc or clang for
assembler generation, I will get something like this:

//target: linux x64
//the same is for mips/x86/arm linux
//gcc -g3 -S test.c

  .file	"test.c"
  .section .debug_abbrev,"", at progbits
.Ldebug_abbrev0:

  .section .debug_info,"", at progbits
.Ldebug_info0:

...

  .section .debug_pubnames,"", at progbits
  .long 0x35           //unit_length
  .value 0x2           //version
  .long .Ldebug_info0  //debug_info_offset <--- !!!


As I read in the DWARF Debugging Standard, the ".long .Ldebug_info0"
attribute in section .debug_pubnames means "The offset from the
beginning of the .debug_info section ...". But the ".long" directive
tells the assembler to store absolute address of the .Ldebug_info0 label
(as is usual in most assemblers), not the section relative address,
which will look like:

.long .Ldebug_info0-.Ldebug_info0

My question is: how will the assembler figure out that it must store an
address from the beginning of a section and not an absolute address? The
same situation is with debug_abbrev_offset in .debug_info section,
debug_info_offset in .debug_pubtypes section, etc.

Our research group is currently creating own assembler, but this problem
looks like context-sensitive task.

Note: The only difference is in MinGW-gcc compiler for Windows PE-COFF,
where .secrel32 directive is used.

Thanks.

Jakub



More information about the Dwarf-Discuss mailing list