Project

General

Profile

Bug #11574

.eh_frame issues and relocations against allocatable sections when compiling software that calls on libffi.

Added by Jeremy Andrews about 1 year ago. Updated about 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
ld, eh_frame, gcc, libffi
Gerrit CR:

Description

I'm running a freshly updated 64-bit [OpenIndiana](https://www.openindiana.org/download/) release on an [Intel Core i7-3770](https://ark.intel.com/content/www/us/en/ark/products/65719/intel-core-i7-3770-processor-8m-cache-up-to-3-90-ghz.html) (should be x86-64/amd64). It's a lot like Solaris 10, even has the same bugs for the most part. Toolchain is as follows:

GCC 7.4.0
illumos ld

I'm trying to port a piece of software to Solaris/illumos without any support from upstream. Libffi seems to compile without issues, but it runs into problems whenever I try and actually use it with anything that calls on it. The software I'm trying to compile has an outdated version of libffi in its tree that gives me the following issues:

0:04.68 ld: fatal: file ../../js/src/libjs_static.a(sysv.o); section [5].eh_frame and file /usr/gcc/7/lib/gcc/i386-pc-solaris2.11/7.4.0/crtendS.o; section [4].eh_frame have incompatible attributes and cannot be merged into a single output section

If I examine sysv.o with readelf -S, I get the following output:

Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 000034 000191 00 AX 0 0 4
[ 2] .rel.text REL 00000000 000478 000008 08 I 7 1 4
[ 3] .data PROGBITS 00000000 0001c5 000000 00 WA 0 0 1
[ 4] .bss NOBITS 00000000 0001c5 000000 00 WA 0 0 1
[ 5] .eh_frame PROGBITS 00000000 0001c8 000060 00 WA 0 0 4
[ 6] .rel.eh_frame REL 00000000 000480 000018 08 I 7 5 4
[ 7] .symtab SYMTAB 00000000 000228 000170 10 8 18 4
[ 8] .strtab STRTAB 00000000 000398 0000e0 00 S 0 0 1
[ 9] .shstrtab STRTAB 00000000 000498 00003e 00 S 0 0 1

So I tried putting a new version of libffi into the tree, and that allows me to get further into the process, but then I get this error with libffi 3.2.1:

2:06.64 Text relocation remains referenced
2:06.64 against symbol offsetin file
2:06.64 .data (section) 0xbb ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0xc9 ../../js/src/libjs_static.a(closures.o)
2:06.64 .rodata.str1.1 (merged string section) 0xd2 ../../js/src/libjs_static.a(closures.o)
2:06.64 .text (section) 0xd7 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0xec ../../js/src/libjs_static.a(closures.o)
2:06.64 .rodata (section) 0xf6 ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x105 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x10b ../../js/src/libjs_static.a(closures.o)
2:06.64 .rodata (section) 0x140 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x145 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x150 ../../js/src/libjs_static.a(closures.o)
2:06.64 .rodata (section) 0x168 ../../js/src/libjs_static.a(closures.o)
2:06.64 .rodata (section) 0x16f ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x186 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x1a9 ../../js/src/libjs_static.a(closures.o)
2:06.64 .rodata (section) 0x1b5 ../../js/src/libjs_static.a(closures.o)
2:06.64 .rodata (section) 0x1c7 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x1cc ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x1e0 ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x1ed ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x20c ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x222 ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x22c ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x241 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x253 ../../js/src/libjs_static.a(closures.o)
2:06.64 .rodata (section) 0x262 ../../js/src/libjs_static.a(closures.o)
2:06.64 .rodata (section) 0x268 ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x280 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x2d5 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x2e3 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x313 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x32d ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x341 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x366 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x37a ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x3a1 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x3b4 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x3d7 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x3e7 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x3ef ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x3fe ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x40d ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x41c ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x442 ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x44e ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x454 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x45e ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x46c ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x47f ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x49c ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x4aa ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x4bb ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x4c4 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x4e4 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x50b ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x519 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x523 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x542 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x576 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x58d ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x5cc ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x5db ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x5f8 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x610 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x619 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x646 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x65f ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x668 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x689 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x68f ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x69d ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x6b3 ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x6d2 ../../js/src/libjs_static.a(closures.o)
2:06.64 .bss (section) 0x6df ../../js/src/libjs_static.a(closures.o)
2:06.64 .data (section) 0x6ef ../../js/src/libjs_static.a(closures.o)
2:06.65 .data (section) 0x704 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x760 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x768 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x771 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x776 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x77c ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x783 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x791 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x7c5 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x86b ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x8ab ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x8f1 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x91d ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x92c ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x97a ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x988 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x992 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x99a ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x9a5 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x9bd ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x9f2 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xa4b ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xa9e ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xb46 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xb5b ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xbbf ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xc61 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xc68 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xc7b ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xc94 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xc9c ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xcab ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xcb6 ../../js/src/libjs_static.a(closures.o)
2:06.65 .data (section) 0xcc2 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xcc8 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xcd2 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xce1 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xcee ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xcfc ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xd06 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xd0e ../../js/src/libjs_static.a(closures.o)
2:06.65 .data (section) 0xd16 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xd33 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xd41 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xd5d ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xd6a ../../js/src/libjs_static.a(closures.o)
2:06.65 .data (section) 0xd82 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xd8e ../../js/src/libjs_static.a(closures.o)
2:06.65 .data (section) 0xd9e ../../js/src/libjs_static.a(closures.o)
2:06.65 .data (section) 0xdb2 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xdca ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xdd1 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xdd7 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xdde ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xde4 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xde9 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xe1c ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xe24 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xe2c ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xe42 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xeb9 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xec2 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xecb ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xed9 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xedf ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xeef ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xef8 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xf01 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xf0e ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xf16 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xf1c ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0xf3d ../../js/src/libjs_static.a(closures.o)
2:06.65 .rodata.cst16 (section) 0xfcf ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x107c ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x1088 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x1099 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x10a9 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x10c1 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x10d4 ../../js/src/libjs_static.a(closures.o)
2:06.65 .bss (section) 0x1133 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1169 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1177 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x11b4 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x11bb ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x11d2 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x121a ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x123c ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1247 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1250 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1261 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1283 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x128b ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1291 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1296 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x12a4 ../../js/src/libjs_static.a(closures.o)
2:06.66 .rodata.cst16 (section) 0x12b5 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x12ba ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x12bf ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x12e0 ../../js/src/libjs_static.a(closures.o)
2:06.66 .rodata.cst16 (section) 0x12e8 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x12ef ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1304 ../../js/src/libjs_static.a(closures.o)
2:06.66 .rodata.cst16 (section) 0x130c ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1313 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1328 ../../js/src/libjs_static.a(closures.o)
2:06.66 .rodata.cst16 (section) 0x1330 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1337 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x134c ../../js/src/libjs_static.a(closures.o)
2:06.66 .rodata.cst16 (section) 0x1354 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x135b ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1370 ../../js/src/libjs_static.a(closures.o)
2:06.66 .rodata.cst16 (section) 0x1378 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x137f ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1394 ../../js/src/libjs_static.a(closures.o)
2:06.66 .rodata.cst16 (section) 0x139c ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x13a3 ../../js/src/libjs_static.a(closures.o)
2:06.66 .rodata.cst16 (section) 0x13af ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x13c0 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x13c7 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x13d8 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x13df ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1403 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x140b ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1414 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1422 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1452 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x145e ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1472 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x14b8 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1523 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1543 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x158b ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x15ac ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x15fd ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x160e ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1638 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1674 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1695 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x169c ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x16a1 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x16cf ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1717 ../../js/src/libjs_static.a(closures.o)
2:06.66 .data (section) 0x1725 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1747 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x174e ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1753 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1758 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x177f ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1893 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x18a0 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x18b5 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x18c3 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x18d1 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x18e5 ../../js/src/libjs_static.a(closures.o)
2:06.66 .data (section) 0x18f2 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1915 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x198d ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x199a ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x19b1 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x19ca ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x19eb ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x19f7 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1a17 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1a5e ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1aa0 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1ab9 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1ac8 ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1b0c ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1b4a ../../js/src/libjs_static.a(closures.o)
2:06.66 .bss (section) 0x1b54 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1b5d ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1b6e ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1b76 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1b7f ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1b92 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1b99 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1bad ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1bd0 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1bf9 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1c0e ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1c41 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1c6e ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1c95 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1ca6 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1cb2 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1d07 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1d10 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1d67 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1de5 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1df2 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1dfc ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1e14 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1e4b ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1e72 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1e9a ../../js/src/libjs_static.a(closures.o)
2:06.67 .data (section) 0x1ea6 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1eac ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1eb6 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1ec5 ../../js/src/libjs_static.a(closures.o)
2:06.67 .data (section) 0x1ed8 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1ef5 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1f03 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1f14 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1f1d ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1f59 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1f65 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1f78 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1f9a ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1fcb ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x1ff2 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2000 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x200a ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2012 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x207c ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x20f3 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x210e ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2139 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x21b2 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x21cf ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x21d6 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x21dc ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x21f3 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2262 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2268 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x226f ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2283 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2298 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x229f ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x22f5 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2312 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2318 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x231f ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2365 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2382 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x238c ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2401 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2432 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2448 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2491 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x24ae ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x24d6 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2541 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2577 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x259e ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x261c ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x263d ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2644 ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x264f ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x266a ../../js/src/libjs_static.a(closures.o)
2:06.67 .bss (section) 0x2674 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2684 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x26ca ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x26ec ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2703 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2756 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2795 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x27ba ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x27fb ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2801 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x280a ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2829 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2831 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2837 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2842 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x284f ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2863 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x28f8 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x294a ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2959 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2966 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2977 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x2996 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x29a3 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x29b6 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x29d5 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x29e2 ../../js/src/libjs_static.a(closures.o)
2:06.68 .bss (section) 0x29f5 ../../js/src/libjs_static.a(closures.o)
2:06.68 .rodata (section) 0x3a2 ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_closure_STDCALL 0x866 ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_closure_REGISTER 0x881 ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_closure_SYSV 0x8b1 ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_closure_THISCALL 0x8d1 ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_closure_FASTCALL 0x8f1 ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_closure_raw_SYSV 0x934 ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x991 ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x9ba ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x3ec ../../js/src/libjs_static.a(win32.o)
2:06.68 .text (section) 0x40c ../../js/src/libjs_static.a(win32.o)
2:06.68 .text (section) 0x42c ../../js/src/libjs_static.a(win32.o)
2:06.68 .text (section) 0x454 ../../js/src/libjs_static.a(win32.o)
2:06.68 .text (section) 0x0 ../../js/src/libjs_static.a(closures.o)
2:06.68 .rodata.str1.1 (merged string section) 0x4 ../../js/src/libjs_static.a(closures.o)
2:06.68 .text (section) 0xc ../../js/src/libjs_static.a(closures.o)
2:06.68 .rodata.str1.1 (merged string section) 0x10 ../../js/src/libjs_static.a(closures.o)
2:06.68 .text (section) 0x18 ../../js/src/libjs_static.a(closures.o)
2:06.68 .rodata.str1.1 (merged string section) 0x1c ../../js/src/libjs_static.a(closures.o)
2:06.68 .text (section) 0x24 ../../js/src/libjs_static.a(closures.o)
2:06.68 .rodata.str1.1 (merged string section) 0x28 ../../js/src/libjs_static.a(closures.o)
2:06.68 .text (section) 0x30 ../../js/src/libjs_static.a(closures.o)
2:06.68 .rodata.str1.1 (merged string section) 0x34 ../../js/src/libjs_static.a(closures.o)
2:06.68 .data (section) 0x8 ../../js/src/libjs_static.a(types.o)
2:06.68 .data (section) 0x14 ../../js/src/libjs_static.a(types.o)
2:06.68 .data (section) 0x20 ../../js/src/libjs_static.a(types.o)
2:06.68 .text (section) 0x0 ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x4 ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x8 ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0xc ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x10 ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x14 ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x18 ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x1c ../../js/src/libjs_static.a(ffi.o)
2:06.68 .text (section) 0x20 ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_prep_cif_machdep 0x20d ../../js/src/libjs_static.a(prep_cif.o)
2:06.68 ffi_prep_cif_machdep 0x36d ../../js/src/libjs_static.a(prep_cif.o)
2:06.68 ffi_prep_cif_machdep 0x4cd ../../js/src/libjs_static.a(prep_cif.o)
2:06.68 ffi_prep_args 0x721 ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_prep_args 0x74a ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_call_SYSV 0x74f ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_call_SYSV 0x9bf ../../js/src/libjs_static.a(ffi.o)
2:06.68 ffi_prep_closure_loc 0x505 ../../js/src/libjs_static.a(prep_cif.o)
2:06.68 pthread_mutex_init 0x98d ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_init 0xd01 ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_init 0x2005 ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_lock 0x467 ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_lock 0x4e9 ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_lock 0x6f4 ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_lock 0xcdb ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_lock 0xda3 ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_lock 0x1e19 ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_lock 0x1ebf ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_unlock 0x421 ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_unlock 0x484 ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_unlock 0x70b ../../js/src/libjs_static.a(closures.o)
2:06.68 pthread_mutex_unlock 0x931 ../../js/src/libjs_static.a(closures.o)
2:06.69 pthread_mutex_unlock 0xd1b ../../js/src/libjs_static.a(closures.o)
2:06.69 pthread_mutex_unlock 0xdb9 ../../js/src/libjs_static.a(closures.o)
2:06.69 pthread_mutex_unlock 0x1e08 ../../js/src/libjs_static.a(closures.o)
2:06.69 pthread_mutex_unlock 0x1edd ../../js/src/libjs_static.a(closures.o)
2:06.69 close 0x24e ../../js/src/libjs_static.a(closures.o)
2:06.69 mkostemp 0x58 ../../js/src/libjs_static.a(closures.o)
2:06.69 errno 0x8d9 ../../js/src/libjs_static.a(closures.o)
2:06.69 errno 0x913 ../../js/src/libjs_static.a(closures.o)
2:06.69 errno 0x1703 ../../js/src/libjs_static.a(closures.o)
2:06.69 sysconf 0x490 ../../js/src/libjs_static.a(closures.o)
2:06.69 sysconf 0x4a1 ../../js/src/libjs_static.a(closures.o)
2:06.69 sysconf 0x966 ../../js/src/libjs_static.a(closures.o)
2:06.69 sysconf 0xd27 ../../js/src/libjs_static.a(closures.o)
2:06.69 sysconf 0xd38 ../../js/src/libjs_static.a(closures.o)
2:06.69 sysconf 0xd4f ../../js/src/libjs_static.a(closures.o)
2:06.69 sysconf 0x1ee9 ../../js/src/libjs_static.a(closures.o)
2:06.69 sysconf 0x1efa ../../js/src/libjs_static.a(closures.o)
2:06.69 sysconf 0x1fde ../../js/src/libjs_static.a(closures.o)
2:06.69 abort 0x4d4 ../../js/src/libjs_static.a(closures.o)
2:06.69 abort 0x1f31 ../../js/src/libjs_static.a(closures.o)
2:06.69 memcpy 0x2d ../../js/src/libjs_static.a(closures.o)
2:06.69 memcpy 0x2e5 ../../js/src/libjs_static.a(ffi.o)
2:06.69 memcpy 0x49e ../../js/src/libjs_static.a(ffi.o)
2:06.69 getenv 0x8a ../../js/src/libjs_static.a(closures.o)
2:06.69 strlen 0xe ../../js/src/libjs_static.a(closures.o)
2:06.69 memmove 0x46f ../../js/src/libjs_static.a(ffi.o)
2:06.69 unlink 0x6b ../../js/src/libjs_static.a(closures.o)
2:06.69 ftruncate 0x118 ../../js/src/libjs_static.a(closures.o)
2:06.69 ftruncate 0x285 ../../js/src/libjs_static.a(closures.o)
2:06.69 ftruncate 0x29e ../../js/src/libjs_static.a(closures.o)
2:06.69 mmap 0x192 ../../js/src/libjs_static.a(closures.o)
2:06.69 mmap 0x1f9 ../../js/src/libjs_static.a(closures.o)
2:06.69 mmap 0x8c6 ../../js/src/libjs_static.a(closures.o)
2:06.69 mmap 0x16f0 ../../js/src/libjs_static.a(closures.o)
2:06.69 munmap 0x277 ../../js/src/libjs_static.a(closures.o)
2:06.69 munmap 0x1fba ../../js/src/libjs_static.a(closures.o)
2:06.69 munmap 0x2031 ../../js/src/libjs_static.a(closures.o)
2:06.69 munmap 0x2420 ../../js/src/libjs_static.a(closures.o)
2:06.69 munmap 0x2564 ../../js/src/libjs_static.a(closures.o)
2:06.69 munmap 0x25d3 ../../js/src/libjs_static.a(closures.o)
2:06.69 munmap 0x27df ../../js/src/libjs_static.a(closures.o)
2:06.69 ld: fatal: relocations remain against allocatable but non-writable sections

I'm not sure why the new version of libffi moves the problem to a different place, mostly in closures.o instead of in sysv.o.

However, one thing does bug me... since this is 64-bit, shouldn't eh_frame be 8 bytes instead of 4, and even if there were a .rel section (which there shouldn't be), shouldn't that be .rela on 64-bit? I've also gotten several suggestions about needing to recompile with -fPIC flags on everything on Solaris/illumos, but I already made sure everything was built with those flags.

I apologize if this is the wrong venue for the bug, it's quite possible that I'm hitting a bug in libffi or in GCC itself, but I really want to get to the bottom of what's happening here, and I was hoping that someone here could point me in the right direction. I've invested so much time and effort into trying to understand the problem that at this point making sense of why this isn't working is as important to me as simply getting the program compiled. I hope I'm not wasting too much of your time here.

#1

Updated by Jeremy Andrews about 1 year ago

I tried using -mimpure-text to force it to compile, but the resulting file was unusable and improperly structured. Whatever it generates without -z,text seems to be non-functional.

#2

Updated by Rich Lowe about 1 year ago

The second set of failures look like your library isn't at all PIC, but should be (-fpic or -fPIC when compiling).

Both sets of failures look like 32bit code, and that you're surprised by that. You're perhaps not giving gcc -m64 either?

The first failure is almost always trying to merge a writable eh_frame with one which is not, if you're setting one up of your own, make sure you match the attributes with those elsewhere in the system (ie, make it writeable)

Whether you specify -ztext doesn't change what we generate, it just changes how and if we complain.

Is the build process creating a static library (libjs_static.a, so I'm guessing), and then linking it into a dynamic library? If so, you want to build libjs_static.a with the PIC flags too.

#3

Updated by Jeremy Andrews about 1 year ago

Ah, I'm just surprised that 32-bit is the default. Normally I have to specify that I want 32-bit binaries if the OS is 64-bit. But this should be fine as a 32-bit build anyway.

Anyway, I've tracked down the problem, and it doesn't seem to be the linker itself, or even libffi. The program I'm trying to compile (a Firefox fork, long story) is actually messing with the section attributes, and it doesn't know what to do with illumos LD. In fact, it comes packaged with a linker mapfile for GNU LD because the trick they use only works with an obscure linker called gold, and pretty much every other linker needs a mapfile.

From the code itself:

"BFD ld doesn't create multiple PT_LOADs as usual when an unknown section exists. Using an implicit linker script to make it fold that section in .data.rel.ro makes it create multiple PT_LOADs. That implicit linker script however makes gold misbehave, first because it doesn't like that the linker script is given after crtbegin.o, and even past that, replaces the default section rules with those from the script instead of supplementing them. Which leads to a lib with a huge load of sections."

And if I remove the mapfile, the GNU LD fails for the exact same reason as illumos LD, and produces the same messed up results. Here's what the GNU linker script looks like:

SECTIONS {
.data.rel.ro : {
*(.kPStaticModules)
}
}

So if my research is correct, what I need to do if I want it to work with the illumos LD is create a Solaris mapfile and use that. I thought it might be a linker bug at first, but apparently not. I assumed this was a MUCH simpler problem than it actually was.

I know for a fact now that it's NOT an issue with your linker and you guys may want to close this bug, but I would like to leave my research here for anyone to find it if that's okay, this took me a very long time to figure out and it's easy for someone to think it's either a linker bug or a library bug. You should know that people assumed it was a bug in your linker for years, and that misinformation about your LD being broken on all Firefox variants is all over the place.

https://bugzilla.mozilla.org/show_bug.cgi?id=938437

This is where the change was made from static module registration to some kind of linker hack that enables them to magically sort their static modules in the correct order without having to maintain a carefully constructed list.

https://github.com/bitwiseworks/mozilla-os2/issues/137

The guy porting Firefox to OS/2 did a better job of explaining precisely what they did and how he was going to implement the same thing without sections on his operating system. It pointed me in the right direction, where I found this.

https://sourceware.org/gdb/onlinedocs/stabs/ELF-Linker-Relocation.html#ELF-Linker-Relocation

He provides two important pieces of information here. One is that GCC doesn't output the symbols that the Sun linker requires to do to the proper relocation of STABs in ELF format. The other is that on Solaris, people have been known to use a zero value to get the address from ELF symbols. And if you look at this official Solaris Firefox repository, you'll see they have this:

https://github.com/oracle/solaris-userland/blob/82dd4adb0eca729372074d62435e00a783d95b1f/components/desktop/firefox/patches/firefox-41-static-xul-components.patch

It uses the exact hack described in the Sourceware article earlier, using a zero value to get the address from ELF symbols. However, this apparently cannot be done on illumos because, as they've stated, GCC doesn't output the symbols that the linker requires in order to do it. In fact, compilation fails entirely if you try that patch on OI, but presumably it works on the Sun compiler/linker combination.

So, it seems like the reason this problem is so intractable is because the illumos linker (assuming it's still similar to the Sun linker) relocates stabs based on ELF symbols that it expects the compiler to provide, while GCC relies on the linker to relocate stabs and doesn't provide those symbols. So basically, on OI, we would appear to be stuck with a situation where it is difficult or impossible to relocate stabs in an automated and orderly fashion because the linker and the compiler don't "speak the same language."

I hope I don't sound ignorant, I just learned about all of this stuff very recently and I have no background in understanding ELF, linkers, STABs, or any of that stuff prior to this.

#4

Updated by Rich Lowe about 1 year ago

So if my research is correct, what I need to do if I want it to work with the
illumos LD is create a Solaris mapfile and use that. I thought it might be a
linker bug at first, but apparently not. I assumed this was a MUCH simpler
problem than it actually was.

You want the LOAD_SEGMENT directive, and ASSIGN_SECTION, I believe. I'm not sure if there's a big reason they're using .data.rel.ro to achieve what they're doing, v. just putting it in an arbitrary loadable segment.

$mapfile_version 2
LOAD_SEGMENT data {
   ASSIGN_SECTION = .kPStaticModules;
}

Seems like it'd do what you want, I'm trying to interpret exactly why they're doing what they're doing with the GNU mapfile and it's possible you'd actually want to create a whole new segment instance

$mapfile_version 2
LOAD_SEGMENT static_modules {
    ASSIGN_SECTION = .kPStaticModules;
    FLAGS = ALLOC;
}

(I'm assuming it's not writeable or executable, if it is, you'd have to adjust the flags).

We don't use stabs any longer, and the problems you're describing with stabs are a bit muddled so I'm not understanding them.

The patch Oracle use for firefox should work, I believe, (at least, it should do what the code is directing it to do. Whether that's correct in all cases I don't know).

#5

Updated by Jeremy Andrews about 1 year ago

Thanks for the mapfiles. For whatever reason, and despite there being a null pointer patch upstream, the relocations don't seem to be going away. It's probably worth noting that LibFFI is written partially in assembler language (especially the parts its choking on), and that could be why it's not acting like it's been compiled with -fPIC. The libjs_static.a file is a static archive, basically, and it's being linked against shared objects (which I imagine isn't helping matters).

I've been studying out the issue more since we last spoke. It seems that the relevance of STABs is that they're trying to do something similar to programming tricks that were often used with STABs. Basically, there was a trick with those that involved dereferencing a null pointer and getting the linker to gather up pointers to all the functions and methods you want to call in one place at link time, and apparently someone found a way to pull off similar tricks using ELF sections.

I can tell you why they're using .data.rel.ro, however. It's a hack that people refer to as the GNU Relro method.

https://mudongliang.github.io/2016/07/11/relro-a-not-so-well-known-memory-corruption-mitigation-technique.html

It has a few benefits, but it effectively disables lazy resolution of symbols and ensures all imported symbols are resolved at startup time, so that they don't have to search through the whole library/list for them. It also marks the sections read-only after they've been initialized by the loader to protect them from memory corruption.

I also managed to find the blog of the programmer who set this up, and it talks about his motivations.

https://glandium.org/blog/?p=1177

"The first iteration I tested a few weeks ago helped validating the idea, but didn’t change much of the binary: the dynamic relocation section still was taking all the space it took before, though its content was mostly empty (we’ll see further below how efficient even the current dumb format is). Once the theory that an injected DT_INIT function could apply the relocations without breaking everything, I went on to implement a program that would actually strip the ELF binary. I won’t get too much into the gory details, but it required PT_LOAD splitting, thus program headers growth, which means moving the following sections, then removing a huge part of the relocations, shrinking the relocations section, injecting our code and the packed relocations as sections, and moving the remaining sections after these new sections, to avoid empty space, but still respecting the proper offsets for both PT_LOAD and the code itself."

And if you look at libxul.mk and some of the files he changed, you see that he has a test for whether you have only one PT_LOAD section or not, and if there's only one PT_LOAD section, the file fails the test. There's also a flag for whether it uses GNU Relro or not, and it's actually kind of weird how much control they try to exercise over the linking process. I can't even really debug the libxul.so that GNU LD produces easily because it's missing all its symbols.

At this point I'm just trying to understand exactly what they did here. It's a little frustrating, but it's also very challenging and interesting. I feel like I'm just short of being able to wrap my mind around it.

#6

Updated by Jeremy Andrews about 1 year ago

Well, I've made some progress. Turns out I was actually having a problem with LibFFI after all on top of the problems with libxul.so, at least with the eh_frame issue and some of the relocations. It turns out the build process was generating two sets of LibFFI objects, and I was examining the wrong one. It also apparently uses the second set if you try to restart the build because there's a different script for that, so I was unaware of the first set's existence.

The objects generated by LibFFI's own configuration file are more or less correct for Solaris, but Mozilla created their own external configuration file that completely screws up Solaris randomly after years of using LibFFI's internal configuration. The new objects are the ones that have the wrong .eh_frame headers. Weirdly, I've never seen this issue documented anywhere before. Probably the other people who solved it felt it was obvious and didn't think it was worthy of a comment or a patch, while the others had to use GNU LD because that's the only solution offered, due to that program having some weird automagic way of fudging the mixture of files with incompatible encodings.

I changed the following things and I'm suddenly getting a lot fewer relocation messages. Mozilla had a configuration file that simply decided that ALL systems using Intel Architecture use the flag HAVE_AS_X86_PCREL, but I remember reading this comment in the LibFFI source code:

"32-bit Solaris 2/x86 uses datarel encoding for PIC. GNU ld before 2.22 doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this."

It doesn't mention OI, but I assume that's true of illumos-based operating systems as well since they are binary compatible with Solaris.

It was also manually setting EH_FRAME_FLAGS to "a" for every architecture that was not ARM. I happen to know from studying things out online and examining binaries on the system that the correct setting for Solaris on x86 seems to be "aw" rather than "a".

Finally, it was also trying to apply HAVE_AS_64_UNWIND_SECTION_TYPE to the 32-bit binaries as well. I'm assuming that should be set to "false" unless I'm building 64-bit only.

I'm not out of the woods yet, but I feel a lot closer to solving this. Now the only text relocations that remain are these, against win32.o (and I have no clue why that file is even being included):

117:18.43 Text relocation remains                     referenced
117:18.43     against symbol            offset    in file
117:18.43 .text (section)                     0x2f4         ../../js/src/libjs_static.a(win32.o)
117:18.43 .text (section)                     0x318         ../../js/src/libjs_static.a(win32.o)
117:18.43 .text (section)                     0x33c         ../../js/src/libjs_static.a(win32.o)
117:18.44 ld: fatal: relocations remain against allocatable but non-writable sections
117:18.44 collect2: error: ld returned 1 exit status

#7

Updated by Jeremy Andrews about 1 year ago

I solved the issue completely. It took me a while to put two and two together, but the solution was just out of reach and I'd been stumbling over it this whole time.

Studying some documentation on avoiding text relocations in assembler code got my brain working along the right lines, along with some documentation about how the Global Offset Table works. I looked closely at the code again, and the old errors I was getting with sysv.o after fixing the .eh_frame issue, and everything clicked into place.

I tried searching win32.S for FDE, because that was the issue I had last time, the code not taking the right branch to get the proper FDE encoding for Solaris... and found that it was hardcoded to use 0x1b (pcrel) encoding! It needed the very same fix that sysv.S warned me about, but for some reason it wasn't implemented here (possibly because no one expected this file to ever be included on a Solaris system, but some general x86-related code somehow got spread into this file so it's always needed on x86).

And because I now know that accessing the GOT table usually involves a relocation of some type, and that that in itself is not a bug, I finally realized it was using the wrong type of relocation. So I basically just copied in the fix from sysv.S that checks whether the OS is Solaris, and if so sets the FDE encoding to 0x30 (datarel), and uses @GOTOFF when attempting to find the FDE initial location. It worked like a charm.

Within win32.S, there were exactly three text relocation errors against the .text section, and there were exactly three times the program attempted to acquire the FDE initial location. Once I fixed them, the program finally linked without a hitch. It works.

https://github.com/athenian200/Solaris-UXP/commit/47963d7aacb1ff223d8b6d992dcfb00afa15d99c

If anyone ever needs to patch an old version of libffi to compile 32-bit Solaris binaries ever again... well, this might become in handly.

Also available in: Atom PDF