ports head -r487783: on armv7 x11/pixman fails to build: /usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC [lld/trunk has afix]
Mark Millard
marklmi at yahoo.com
Sat Nov 17 03:35:27 UTC 2018
Such timing: https://reviews.llvm.org/D53444 indicates
commits to lld/trunk/ELF/Arch/ARM.cpp today (2018-Nov-16)
to support R_ARM_V4BX in lld.
(No update text below. The above just did not fit well.)
On 2018-Nov-16, at 18:49, Mark Millard <marklmi at yahoo.com> wrote:
> On 2018-Nov-16, at 18:15, Mark Millard <marklmi at yahoo.com> wrote:
>
>>
>> I finally figured out parts of the issue, I think.
>> At least how the V_ARM_V4BX use is getting there
>> despite lld's status for handling it . . .
>>
>> On armv7:
>>
>> # more test_bx_lr.S
>> .text
>> .arch armv6
>> .object_arch armv4
>> .arm
>> .altmacro
>> .p2align 2
>> .func fname
>> .global fname
>> .hidden fname
>> .type fname, %function
>> fname:
>> bx lr
>>
>> (I got those lines from the failing port's .S files,
>> including includes. Note the .object_arch armv4 use
>> and the forced armv6, not armv7.)
>
> For reference relative to the use of .object_arch armv4 :
>
> # grep -r object_arch /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0/pixman/ | more
> /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0/pixman/pixman-arm-neon-asm.S: .object_arch armv4
> /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0/pixman/pixman-arm-simd-asm-scaled.S: .object_arch armv4
> /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0/pixman/pixman-arm-neon-asm-bilinear.S:.object_arch armv4
> /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0/pixman/pixman-arm-simd-asm.S: .object_arch armv4
>
> Without .object_arch armv4 the assembler involved does not output
> the V_ARM_V4BX *ABS* relocation records (adjusted the small example):
>
> # objdump -x test_bx_lr.o | more
>
> test_bx_lr.o: file format elf32-littlearm
> test_bx_lr.o
> architecture: arm, flags 0x00000010:
> HAS_SYMS
> start address 0x00000000
> private flags = 5000000: [Version5 EABI]
>
> Sections:
> Idx Name Size VMA LMA File off Algn
> 0 .text 00000004 00000000 00000000 00000034 2**2
> CONTENTS, ALLOC, LOAD, READONLY, CODE
> 1 .data 00000000 00000000 00000000 00000038 2**0
> CONTENTS, ALLOC, LOAD, DATA
> 2 .bss 00000000 00000000 00000000 00000038 2**0
> ALLOC
> 3 .ARM.attributes 0000001b 00000000 00000000 00000038 2**0
> CONTENTS, READONLY
> SYMBOL TABLE:
> 00000000 l d .text 00000000 .text
> 00000000 l d .data 00000000 .data
> 00000000 l d .bss 00000000 .bss
> 00000000 l d .ARM.attributes 00000000 .ARM.attributes
> 00000000 g F .text 00000000 .hidden fname
>
>
>
>> # clang -target armv7-unknown-freebsd13.0-gnueabihf -O -pipe -no-integrated-as -MT test_bx_lr.lo -MD -MP -MF test_bx_lr.Tpo -c test_bx_lr.S -fPIC -DPIC -o test_bx_lr.o
>>
>> (The -target is not necessary. I just choose to be explicit.)
>>
>> # objdump -x test_bx_lr.o | more
>>
>> test_bx_lr.o: file format elf32-littlearm
>> test_bx_lr.o
>> architecture: armv4, flags 0x00000011:
>> HAS_RELOC, HAS_SYMS
>> start address 0x00000000
>> private flags = 5000000: [Version5 EABI]
>>
>> Sections:
>> Idx Name Size VMA LMA File off Algn
>> 0 .text 00000004 00000000 00000000 00000034 2**2
>> CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
>> 1 .data 00000000 00000000 00000000 00000038 2**0
>> CONTENTS, ALLOC, LOAD, DATA
>> 2 .bss 00000000 00000000 00000000 00000038 2**0
>> ALLOC
>> 3 .ARM.attributes 0000001b 00000000 00000000 00000038 2**0
>> CONTENTS, READONLY
>> SYMBOL TABLE:
>> 00000000 l d .text 00000000 .text
>> 00000000 l d .data 00000000 .data
>> 00000000 l d .bss 00000000 .bss
>> 00000000 l d .ARM.attributes 00000000 .ARM.attributes
>> 00000000 g F .text 00000000 .hidden fname
>>
>>
>> RELOCATION RECORDS FOR [.text]:
>> OFFSET TYPE VALUE
>> 00000000 R_ARM_V4BX *ABS*
>>
>>
>> truss for that cc command reports looking in many
>> places for as, finally finding /usr/local/bin/as :
>>
>> access("/usr/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/bin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>>
>> (Note: based on WITHOUT_BINUTILS= for buildworld the above would normally
>> not be found. But for WITH_BINUTILS= the host as would be found.)
>>
>> access("/sbin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/sbin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/sbin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/home/markmi/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/sbin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/bin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/sbin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/bin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/sbin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/bin/as",X_OK|R_OK) = 0 (0x0)
>>
>> (Note the /usr/home/markmi/bin/armv7-unknown-freebsd13.0-gnueabihf-as attempt
>> before the one actually found and used. I would not have guessed the
>> need to worry about such a place.)
>>
>> Then follows:
>>
>> fstatat(AT_FDCWD,"/usr/local/bin/as",{ mode=-r-xr-xr-x ,inode=80287,size=21817416,blksize=32768 },0x0) = 0 (0x0)
>> __sysctl(0xbfbfe020,0x2,0xbfbfe018,0xbfbfe01c,0xe,0x236c9140) = 0 (0x0)
>> access("/usr/bin/clang",F_OK) = 0 (0x0)
>> vfork() = 61461 (0xf015)
>> wait4(61461,{ EXITED,val=0 },0x0,0x0) = 61461 (0xf015)
>> access("/usr/local/bin/as",F_OK) = 0 (0x0)
>> vfork() = 61462 (0xf016)
>> wait4(61462,{ EXITED,val=0 },0x0,0x0) = 61462 (0xf016)
>> access("/tmp/test_bx_lr-0c7bf8.s",W_OK) = 0 (0x0)
>> fstatat(AT_FDCWD,"/tmp/test_bx_lr-0c7bf8.s",{ mode=-rw-r--r-- ,inode=802647,size=210,blksize=32768 },0x0) = 0 (0x0)
>> fstatat(AT_FDCWD,"/tmp/test_bx_lr-0c7bf8.s",{ mode=-rw-r--r-- ,inode=802647,size=210,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
>> fstatat(AT_FDCWD,"/tmp/test_bx_lr-0c7bf8.s",{ mode=-rw-r--r-- ,inode=802647,size=210,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
>> unlink("/tmp/test_bx_lr-0c7bf8.s") = 0 (0x0)
>>
>> llvm/clang is not providing the assembler used for -no-integrated-as .
>> This would appear to imply that a system without ports or other such
>> can not use -no-integrated-as with clang for buildworld buildkernel.
>>
>> In my normal armv7 command line context the above ends up using:
>>
>> # /usr/local/bin/as -v
>> GNU assembler version 2.30 (armv7-portbld-freebsd13.0) using BFD version (GNU Binutils) 2.30
>>
>> So a GNU toolchain's as is actually in control of what goes in
>> the .o file in many contexts. It is not clear that all the
>> alternatives are equivalent for R_ARM_V4BX being generated
>> or not.
>>
>>
>> Simplifying the command (but still showing target):
>>
>> # clang -target armv7-unknown-freebsd13.0-gnueabihf -pipe -no-integrated-as -c test_bx_lr.S -o test_bx_lr.o
>>
>> # objdump -x test_bx_lr.o | more
>>
>> test_bx_lr.o: file format elf32-littlearm
>> test_bx_lr.o
>> architecture: armv4, flags 0x00000011:
>> HAS_RELOC, HAS_SYMS
>> start address 0x00000000
>> private flags = 5000000: [Version5 EABI]
>>
>> Sections:
>> Idx Name Size VMA LMA File off Algn
>> 0 .text 00000004 00000000 00000000 00000034 2**2
>> CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
>> 1 .data 00000000 00000000 00000000 00000038 2**0
>> CONTENTS, ALLOC, LOAD, DATA
>> 2 .bss 00000000 00000000 00000000 00000038 2**0
>> ALLOC
>> 3 .ARM.attributes 0000001b 00000000 00000000 00000038 2**0
>> CONTENTS, READONLY
>> SYMBOL TABLE:
>> 00000000 l d .text 00000000 .text
>> 00000000 l d .data 00000000 .data
>> 00000000 l d .bss 00000000 .bss
>> 00000000 l d .ARM.attributes 00000000 .ARM.attributes
>> 00000000 g F .text 00000000 .hidden fname
>>
>>
>> RELOCATION RECORDS FOR [.text]:
>> OFFSET TYPE VALUE
>> 00000000 R_ARM_V4BX *ABS*
>>
>>
>> Without the -no-integrated-as the notation in the file is rejected,
>> with "unknown directive" for .func .
>>
>>
>>
>> Using poudriere bulk with -i and installing binutils in the
>> session, I see the same inside my amd64->armv7 cross build
>> environment. So there still is the question of how R_ARM_V4BX
>> is handled by various lld's in various contexts. (Or whatever
>> linker is being used if it is not lld.)
>>
>> Back to amd64 land . . .
>>
>> Renaming the existing as files so we can see all the places
>> searched before not-found is declared (on amd64 with -target
>> specified):
>>
>> access("/usr/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/bin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/bin/x86_64-unknown-freebsd13.0-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/sbin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/sbin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/sbin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/home/markmi/bin/armv7-unknown-freebsd13.0-gnueabihf-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/sbin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/bin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/sbin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/bin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/sbin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/bin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/home/markmi/bin/as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/sbin/x86_64-unknown-freebsd13.0-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/bin/x86_64-unknown-freebsd13.0-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/sbin/x86_64-unknown-freebsd13.0-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/bin/x86_64-unknown-freebsd13.0-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/sbin/x86_64-unknown-freebsd13.0-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/local/bin/x86_64-unknown-freebsd13.0-as",X_OK|R_OK) ERR#2 'No such file or directory'
>> access("/usr/home/markmi/bin/x86_64-unknown-freebsd13.0-as",X_OK|R_OK) ERR#2 'No such file or directory'
>>
>> (Note: It actually explicitly tries to use the x86_64 assembler if it
>> does not find an armv7 or a generically pathed one. The generically
>> pathed ones would normally also be x86_64 ones.)
>>
>>
>> Another thing of note (using aarch64 as an example):
>>
>> /usr/local/aarch64-unknown-freebsd13.0/bin/as
>>
>> does not appear to be someplace that clang would find as
>> but is a place devel/aarch64-binutils puts one.
===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
More information about the freebsd-ports
mailing list