amd64 kmod symbol relocation

Dixit, Amol dixit at netapp.com
Wed Jun 6 23:53:27 UTC 2007


Hi,
I am having issues loading a test module on amd64 platform, ONLY when 
its loaded below 2gb (0x80000000).
The module is trying to access a function 'printf()' in a shared library 
which is beyond the 2gb boundary but the runtime loader is trying to 
relocate the symbol to some other offset in its .text section.

(gdb) disass alloc_loader
Dump of assembler code for function alloc_loader:
0xffffff000b3a2000 <alloc_loader+0>:    push   %rbp
0xffffff000b3a2001 <alloc_loader+1>:    mov    $0xb3a2026,%rdi
0xffffff000b3a2008 <alloc_loader+8>:    xor    %eax,%eax
0xffffff000b3a200a <alloc_loader+10>:   mov    %rsp,%rbp
0xffffff000b3a200d <alloc_loader+13>:   callq  0x8024b730            
<---- call printf()
0xffffff000b3a2012 <alloc_loader+18>:   leaveq
0xffffff000b3a2013 <alloc_loader+19>:   xor    %eax,%eax
0xffffff000b3a2015 <alloc_loader+21>:   retq

(gdb) p/x frame.tf_rip
$10 = 0xffffff008024b730                  <--- panic "privileged 
instruction fault" address
(gdb) info sym 0xffffff008024b730
No symbol matches 0xffffff008024b730.      <--- nothing here, hence the 
panic!
(gdb) info sym 0xffffffff8024b730
printf in section .text                           <--- here it is! 
beyond 2gb (sign-extended)

The module is compiled with kernel memory model (mcmodel=kernel). Any 
ideas why the relocation is failing in this manner? How do we force 
kldload to use addresses above 2gb?

Object code looks like this:

alloc_loader():
   0:   55                      push   %rbp
   1:   48 c7 c7 00 00 00 00    mov    $0x0,%rdi
                        4: R_X86_64_32S .rodata.str1.1+0x6
   8:   31 c0                   xor    %eax,%eax
   a:   48 89 e5                mov    %rsp,%rbp
   d:   e8 00 00 00 00          callq  12 <alloc_loader+0x12>
                        e: R_X86_64_PC32        printf+0xfffffffffffffffc
  12:   c9                      leaveq 
  13:   31 c0                   xor    %eax,%eax
  15:   c3                      retq   

I believe relocation types R_X86_64_32S and R_X86_64_PC32 require top 33 bits 1 or 0 and in
case of 'printf' 0xffffff008024b730 doesn't obey it...I guess!

Thanks,
Amol






More information about the freebsd-amd64 mailing list