Skip to contentSkip to conversation

unmatched R_MIPS_HI16/LO16 on gcc 3.4.3

DISCUSSION [email protected] 3 participants 4 messages Jul 25, 2006 – Jul 31, 2006 MIPS

lore
Share & tools
lore
#0 lore raw

Sorry for disturbing you.

I met similar problem as Stanislaw Skowronek, but for gcc 3.4.3. I created a kernel module, when insmod, kernel reported "dangerous relocation". I traced the bug, found unmatched R_MIPS_HI16/LO16 in module's elf file, and kernel refused to relocate:
...

00015a5c  00039a05 R_MIPS_HI16       0000000c   tos_net_debug
00015a68  00000204 R_MIPS_26         00000000   .text
00015a64  00046005 R_MIPS_HI16       0006b598   arp_proxy_list
00015a6c  00046006 R_MIPS_LO16       0006b598   arp_proxy_list

...

My problem arised when expression on tos_net_debug could be optimized out, it seemed like gcc optimized out the LO16, but left HI16.

The original discussion on similar problem is at
http://www.linux-mips.org/archives/linux-mips/2005-05/msg00097.html

thanks very much

#1 lore raw
Quoted 9 lines · On Tue, Jul 25, 2006 at 10:49:56AM +0800, [email protected] wrote:

I met similar problem as Stanislaw Skowronek, but for gcc 3.4.3. I created a kernel module, when insmod, kernel reported "dangerous relocation". I traced the bug, found unmatched R_MIPS_HI16/LO16 in module's elf file, and kernel refused to relocate:
...

00015a5c  00039a05 R_MIPS_HI16       0000000c   tos_net_debug
00015a68  00000204 R_MIPS_26         00000000   .text
00015a64  00046005 R_MIPS_HI16       0006b598   arp_proxy_list
00015a6c  00046006 R_MIPS_LO16       0006b598   arp_proxy_list
Quoted 7 lines

...

My problem arised when expression on tos_net_debug could be optimized out, it seemed like gcc optimized out the LO16, but left HI16.

The original discussion on similar problem is at
http://www.linux-mips.org/archives/linux-mips/2005-05/msg00097.html

Do you have a testcase, a kernel .config file to trigger this?

Ralf

#2 lore raw

Attachment is a testsuit. It costed me a week to make this testsuit.

If I added -mno-explicit-relocs -mno-split-addresses to makefile, this bug disappeared. Is there any performance difference with and without these flags ?

Thanks!

----- Original Message -----
From: "Ralf Baechle" <[email protected]>
To: <[email protected]>
Cc: <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>
Sent: Tuesday, July 25, 2006 11:44 AM
Subject: Re: unmatched R_MIPS_HI16/LO16 on gcc 3.4.3

Quoted 3 lines · On Tue, Jul 25, 2006 at 10:49:56AM +0800, [email protected] wrote:
Quoted 2 lines

I met similar problem as Stanislaw Skowronek, but for gcc 3.4.3. I

created a

Quoted 1 line
Quoted 1 line

kernel module, when insmod, kernel reported "dangerous relocation". I

traced

Quoted 1 line
Quoted 1 line

the bug, found unmatched R_MIPS_HI16/LO16 in module's elf file, and

kernel

Quoted 9 lines
Quoted 9 lines

refused to relocate:
...

00015a5c  00039a05 R_MIPS_HI16       0000000c   tos_net_debug
00015a68  00000204 R_MIPS_26         00000000   .text
00015a64  00046005 R_MIPS_HI16       0006b598   arp_proxy_list
00015a6c  00046006 R_MIPS_LO16       0006b598   arp_proxy_list

...

My problem arised when expression on tos_net_debug could be optimized

out,

Quoted 9 lines
Quoted 4 lines

it seemed like gcc optimized out the LO16, but left HI16.

The original discussion on similar problem is at
http://www.linux-mips.org/archives/linux-mips/2005-05/msg00097.html

Do you have a testcase, a kernel .config file to trigger this?

Ralf

#3 lore raw
Quoted 2 lines · [email protected] wrote:

Attachment is a testsuit. It costed me a week to make this testsuit.

FWIW, I can't reproduce the failure with Debian's gcc 3.4.6. ISTR this bug was fixed in later 3.4.x versions.

Quoted 3 lines

If I added -mno-explicit-relocs -mno-split-addresses to makefile, this bug disappeared. Is there any performance difference with and without these flags ?

-mno-explicit-relocs will degrade the efficiency of the compiler's instruction scheduling since some macro expansions are left to the assembler in that case. It will likely affect both execution speed and code size.

Thiemo