This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A 48 byte kernel module/cfi load mystery


Kernel modules are relocatable objects, so those addresses you see are as
placed by libdwfl.  If you pass them to dwfl_module_relocate_address you
will get their section-relative offsets.

Let's take an example object:

	$ eu-readelf -S /usr/lib/debug/lib/modules/2.6.33.5-124.fc13.x86_64/kernel/fs/ext2/ext2.ko.debug
	There are 44 section headers, starting at offset 0x245418:

	Section Headers:
	[Nr] Name                 Type         Addr             Off      Size     ES Flags Lk Inf Al
	[ 0]                      NULL         0000000000000000 00000000 00000000  0        0   0  0
*	[ 1] .note.gnu.build-id   NOTE         0000000000000000 00000040 00000024  0 A      0   0  4
*	[ 2] .text                NOBITS       0000000000000000 00000064 00009c8c  0 AX     0   0  4
	<...>

Since the allocated section before it has size 0x24, that will be the
address where .text is placed.  Now let's look at the data:

	$ eu-readelf -r --debug-dump=frames /usr/lib/debug/lib/modules/2.6.33.5-124.fc13.x86_64/kernel/fs/ext2/ext2.ko.debug
	<...>
	Relocation section [33] '.rela.debug_frame' for section [32] '.debug_frame' at offset 0x1aa048 contains 288 entries:
	  Offset              Type            Value               Addend Name
	  0x000000000000001c  X86_64_32       000000000000000000      +0 .debug_frame
*	  0x0000000000000020  X86_64_64       000000000000000000      +0 .text
	  0x0000000000000054  X86_64_32       000000000000000000      +0 .debug_frame
	  0x0000000000000058  X86_64_64       000000000000000000     +93 .text
	<...>
	DWARF section [32] '.debug_frame' at offset 0x1a6fb8:

	 [     0] CIE length=20
	   CIE_id:                   18446744073709551615
	   version:                  3
	   augmentation:             ""
	   code_alignment_factor:    1
	   data_alignment_factor:    -8
	   return_address_register:  16

	   Program:
	     def_cfa r7 (rsp) at offset 8
	     offset_extended_sf r16 (rip) at cfa-8
	     nop
	     nop
	     nop
	     nop
	     nop

	 [    18] FDE length=52 cie=[     0]
	   CIE_pointer:              0
*	   initial_location:         0x24
	   address_range:            0x5d

	   Program:
	     advance_loc4 8 to 0x8
	     def_cfa_offset 16
	     offset_extended_sf r6 (rbp) at cfa-16
	     advance_loc4 3 to 0xb
	     def_cfa_register r6 (rbp)
	     advance_loc4 81 to 0x5c
	     restore r6 (rbp)
	     def_cfa r7 (rsp) at offset 8
	     nop
	     nop
	     nop
	     nop
	     nop
	     nop
	<...>

The decoded initial_location in the FDE at 0x18 is shown as 0x24.  
You can see from the reloc records that there is a reloc right there
(at 0x20, in the FDE header), for 0 bytes into the .text section.

I've just changed eu-readelf (for the eventual 0.149) to print FDE
addresses like it does others from DWARF, so (without -N) it shows:

	 [    18] FDE length=52 cie=[     0]
	   CIE_pointer:              0
	   initial_location:         .text+000000000000000000 <ext2_bg_has_super>
	   address_range:            0x5d

I hope that helps avoid future confusion about this.


Thanks,
Roland


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]