NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-vax/46715: Relocation in .text section in vax does not work



>Number:         46715
>Category:       port-vax
>Synopsis:       Relocation in .text section in vax does not work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-vax-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 17 16:00:00 +0000 2012
>Originator:     Paul Koning
>Release:        5.1
>Organization:
>Environment:
NetBSD pk3900 5.1 NetBSD 5.1 (GENERIC) #0: Thu Jul 12 21:33:26 EDT 2012  
pkoning%plato4.lab.equallogic.com@localhost:/buildarea/objdir.vax/buildarea/netbsd-51/src/sys/arch/vax/compile/GENERIC
 vax

>Description:
I ran into this problem trying to build gmp 5.0.5 on netbsd/vax.  There are 
some assembly language files that are linked into a shared library; those 
contain code like this:

   jmp   Loop(%r5)

(to jump into the middle of an unrolled loop).  So that assembles into a 
reference to label Loop, which is relocatable.  

The compiler is happy; the linker warns:  "Warning: R_VAX_32 relocation to 
0xnnnn from .text section".  At runtime, I get a segfault in ld.elf_so at the 
point where it tries to apply that relocation; apparently it didn't flip the 
segment to be writable at this point as most other ld.elf_so ports do.

This particular bit of code is not hard to change for a workaround:

   jmp    Loop[%r5]

but that requires a source level fix and in other cases it might not be so easy.
>How-To-Repeat:
Here's a simple test program bug.s:

# This shows an ld.elf_so bug

        .text

        .globl  foo
foo:
        .word   0
        clrl    %r0
        jmp     bug(%r0)
bug:
        ret

Assemble (gcc -c bug.s) then link (ld --shared -o libbug.so bug.o).  The link 
step shows the warning I mentioned.

Link another file with this shared library, for example:


extern void foo(void);

int main (int c, char **v)
{
    foo ();
    return 0;
}

gcc bugmain.c -lbug -L .
./a.out

will show the segfault.
>Fix:



Home | Main Index | Thread Index | Old Index