This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
.debug_frame section - incorrect relocations?
- From: Alexey Neyman <stilor at att dot net>
- To: binutils at sourceware dot org
- Date: Thu, 05 Dec 2013 23:38:51 -0800
- Subject: .debug_frame section - incorrect relocations?
- Authentication-results: sourceware.org; auth=none
Hi,
I am working on an application that includes some limited self-debugging
capabilities, and to support that, I am including .debug_* sections into the
loadable segment. This mostly works, but I am facing an issue with
.debug_frame section.
According to DWARF spec, the .debug_frame section FDE records contain a CIE
link in form of an offset from the beginning of the section. However, the
records generated by binutils are as follows for a simple program:
--------
$ readelf -r -x .debug_frame test.o
Relocation section '.rela.debug_frame' at offset 0x390 contains 2 entries:
Offset Info Type Sym. Value Sym. Name +
Addend
00000000001c 00040000000a R_X86_64_32 0000000000000000 .debug_frame + 0
000000000020 000100000001 R_X86_64_64 0000000000000000 .text + 0
Hex dump of section '.debug_frame':
NOTE: This section has relocations against it, but these have NOT been
applied to this dump.
0x00000000 14000000 ffffffff 01000178 100c0708 ...........x....
0x00000010 90010000 00000000 14000000 00000000 ................
0x00000020 00000000 00000000 01000000 00000000 ................
------
Clearly, this would only comply to DWARF spec if the .debug_frame sections are
collected by linker as absolute sections. If the linker script places them at
some other location (e.g. into text ELF segment along with .text and .rodata),
the FDEs will contain absolute addresses, not offsets into .debug_frame -
which would not conform to DWARF spec.
So, the question is, is it possible to express the behavior described by DWARF
spec ("insert an address that is offset of the specified symbol from the start
of the specified output section") in x86-64 and i386 relocations? If it is,
shouldn't gas generate such relocations?
If not - are there any solutions to have .debug_frame at non-zero address, yet
with DWARF-conformat CIE links?
For the reference, text of the test.s file:
[[[
.cfi_sections .debug_frame
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.cfi_startproc
ret
.cfi_endproc
.size foo, .-foo
]]]
Regards,
Alexey.