The follow mips asm fragment when assembled and link -shared the following error messages from ld: mips64el--netbsd-as -KPIC -mabi=new -o devname.so devname.o mips64el--netbsd-ld: error: /tmp/devname.so contains a reloc (0x0000000000000914) for section .text that references a non-existent global symbol mips64el--netbsd-ld: final link failed: Bad value .file 1 "devname.c" .section .mdebug.abiN32 .previous .abicalls addiu $sp,$sp,-16 move $12,$28 lui $28,%hi(%neg(%gp_rel(_devname))) addu $28,$28,$25 addiu $28,$28,%lo(%neg(%gp_rel(_devname))) lw $2,%got_page($LC4+5)($28) addiu $2,$2,%got_ofst($LC4+5) move $28,$12 j $31 addiu $sp,$sp,16 .set macro .set reorder .end _devname .size _devname, .-_devname However, if the follow diff is applied then the error goes away. @@ -25,8 +25,9 @@ lui $28,%hi(%neg(%gp_rel(_devname))) addu $28,$28,$25 addiu $28,$28,%lo(%neg(%gp_rel(_devname))) - lw $2,%got_page($LC4+5)($28) - addiu $2,$2,%got_ofst($LC4+5) +$LC5=$LC4+5 + lw $2,%got_page($LC5)($28) + addiu $2,$2,%got_ofst($LC5) move $28,$12 j $31 addiu $sp,$sp,16 Obviously that change should not caused anything to change but it did. It seems that when the reloc is emitted, the $LC4 + 5 should have been changed to .rodata.str1.8 + offset($LC4) + 5. This bug exists in 2.16 and in 2.19 and on HEAD.
This is actually a bug in objcopy: gas/as-new -KPIC -mabi=n32 -o /tmp/devname.so /tmp/devname.s ld/ld-new -shared -o /tmp/devname.so.1 /tmp/devname.so binutils/objcopy -x /tmp/devname.so ld/ld-new -shared -o /tmp/devname.so.1 /tmp/devname.so ld/ld-new: error: /tmp/devname.so contains a reloc (0x0000000000000914) for section .text that references a non-existent global symbol ld/ld-new: final link failed: Bad value
However I'd like re-iterate that gas should have emitted the reloc with the local symbol in the first place.
Your asm snippet doesn't assemble. I added a .ent directive, and definitions for _devname and $LC4, and current mainline then assembles and links OK. Please correct your testcase.
.