Discussion:
[Nix-dev] ldconfig problem with patchelf and 64-bit libs
Tim Crowder
2010-05-05 21:18:17 UTC
Permalink
I'm using patchelf to add rpath to some libraries, both 32 and 64-bit.
They both seem to work with executables, but ldconfig complains about
the 64-bit lib:
/sbin/ldconfig: file ./liblwes64.so is truncated
I've looked at the section offsets and sizes, etc, and I didn't yet find
anything that
points past the end-of-file. Also, readelf hasn't complained about anything.
I'm including the file listing and some readelf output.

Any idea what might be wrong?
Let me know if there's any other info I can provide...

Thanks!

-timrc

=================================================================================

[***@chiefredbull:lwes-rel4-64]ls -l
-rwxr-xr-x 1 crowdert 188976 May 4 17:19 liblwes64.so

[***@chiefredbull:lwes-rel4-64]readelf -WhSl
liblwes64.so [~/work/pst/lwes/tmp/rpath]
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x4a50
Start of program headers: 184320 (bytes into file)
Start of section headers: 165352 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 6
Size of section headers: 64 (bytes)
Number of section headers: 37
Section header string table index: 32

Section Headers:
[Nr] Name Type Address Off Size
ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000
00 0 0 0
[ 1] .hash HASH 0000000000000158 000158 0006e8
04 A 2 0 8
[ 2] .dynsym DYNSYM 0000000000000840 000840 0016c8
18 A 36 13 8
[ 3] .gnu.version VERSYM 0000000000002e18 002e18 0001e6
02 A 2 0 2
[ 4] .gnu.version_r VERNEED 0000000000003000 003000 000030
00 A 36 1 8
[ 5] .rela.dyn RELA 0000000000003030 003030 000528
18 A 2 0 8
[ 6] .rela.plt RELA 0000000000003558 003558 000c78
18 A 2 8 8
[ 7] .init PROGBITS 00000000000041d0 0041d0 000018
00 AX 0 0 4
[ 8] .plt PROGBITS 00000000000041e8 0041e8 000860
10 AX 0 0 4
[ 9] .text PROGBITS 0000000000004a50 004a50 006578
00 AX 0 0 16
[10] .fini PROGBITS 000000000000afc8 00afc8 00000e
00 AX 0 0 4
[11] .rodata PROGBITS 000000000000afe0 00afe0 000e77
00 A 0 0 32
[12] .eh_frame_hdr PROGBITS 000000000000be58 00be58 00047c
00 A 0 0 4
[13] .eh_frame PROGBITS 000000000000c2d8 00c2d8 000ffc
00 A 0 0 8
[14] .ctors PROGBITS 000000000010d2d8 00d2d8 000010
00 WA 0 0 8
[15] .dtors PROGBITS 000000000010d2e8 00d2e8 000010
00 WA 0 0 8
[16] .jcr PROGBITS 000000000010d2f8 00d2f8 000008
00 WA 0 0 8
[17] .data.rel.ro PROGBITS 000000000010d300 00d300 000058
00 WA 0 0 8
[18] .got PROGBITS 000000000010d508 00d508 000140
08 WA 0 0 8
[19] .got.plt PROGBITS 000000000010d648 00d648 000440
08 WA 0 0 8
[20] .data PROGBITS 000000000010da88 00da88 000030
00 WA 0 0 8
[21] .bss NOBITS 000000000010dab8 00dab8 0000a0
00 WA 0 0 8
[22] .comment PROGBITS 0000000000000000 00dab8 0002b0
00 0 0 1
[23] .debug_aranges PROGBITS 0000000000000000 00dd68 0001e0
00 0 0 1
[24] .debug_pubnames PROGBITS 0000000000000000 00df48 001174
00 0 0 1
[25] .debug_info PROGBITS 0000000000000000 00f0bc 007bad
00 0 0 1
[26] .debug_abbrev PROGBITS 0000000000000000 016c69 001420
00 0 0 1
[27] .debug_line PROGBITS 0000000000000000 018089 001d0c
00 0 0 1
[28] .debug_frame PROGBITS 0000000000000000 019d98 0013c0
00 0 0 8
[29] .debug_str PROGBITS 0000000000000000 01b158 001cec
01 MS 0 0 1
[30] .debug_loc PROGBITS 0000000000000000 01ce44 00ace9
00 0 0 1
[31] .debug_ranges PROGBITS 0000000000000000 027b2d 000960
00 0 0 1
[32] .shstrtab STRTAB 0000000000000000 02848d 000154
00 0 0 1
[33] .symtab SYMTAB 0000000000000000 028f28 001ec0
18 34 98 8
[34] .strtab STRTAB 0000000000000000 02ade8 0014f3
00 0 0 1
[35] .dynamic DYNAMIC 000000000010e150 02d150 0001c0
10 WA 36 0 8
[36] .dynstr STRTAB 000000000010e310 02d310 000f1e
00 A 0 0 8
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD 0x000000 0x0000000000000000 0x0000000000000000
0x00d2d4 0x00d2d4 R E 0x100000
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000
0x000000 0x000000 RW 0x8
GNU_EH_FRAME 0x00be58 0x000000000000be58 0x000000000000be58
0x00047c 0x00047c R 0x4
LOAD 0x00d2d8 0x000000000010d2d8 0x000000000010d2d8
0x0007e0 0x000880 RW 0x100000
LOAD 0x02d000 0x000000000010e000 0x000000000010e000
0x001230 0x001230 RW 0x1000
DYNAMIC 0x02d150 0x000000000010e150 0x000000000010e150
0x0001c0 0x0001c0 RW 0x8

Section to Segment mapping:
Segment Sections...
00 .hash .dynsym .gnu.version .gnu.version_r .rela.dyn .rela.plt
.init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
01
02 .eh_frame_hdr
03 .ctors .dtors .jcr .data.rel.ro .got .got.plt .data .bss
04 .dynamic
05 .dynamic
Lluís Batlle i Rossell
2010-05-06 14:50:54 UTC
Permalink
I used patchelf with x86_64 libraries, but I did not use ldconfig with them.
For what I tried, all worked.

Do those x86_64 libraries patchelf'ed fail *only* according to ldconfig?
Post by Tim Crowder
I'm using patchelf to add rpath to some libraries, both 32 and 64-bit.
They both seem to work with executables, but ldconfig complains
/sbin/ldconfig: file ./liblwes64.so is truncated
I've looked at the section offsets and sizes, etc, and I didn't yet
find anything that
points past the end-of-file. Also, readelf hasn't complained about anything.
I'm including the file listing and some readelf output.
Any idea what might be wrong?
Let me know if there's any other info I can provide...
Thanks!
-timrc
=================================================================================
-rwxr-xr-x 1 crowdert 188976 May 4 17:19 liblwes64.so
[~/work/pst/lwes/tmp/rpath]
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x4a50
Start of program headers: 184320 (bytes into file)
Start of section headers: 165352 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 6
Size of section headers: 64 (bytes)
Number of section headers: 37
Section header string table index: 32
[Nr] Name Type Address Off
Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000
000000 00 0 0 0
[ 1] .hash HASH 0000000000000158 000158
0006e8 04 A 2 0 8
[ 2] .dynsym DYNSYM 0000000000000840 000840
0016c8 18 A 36 13 8
[ 3] .gnu.version VERSYM 0000000000002e18 002e18
0001e6 02 A 2 0 2
[ 4] .gnu.version_r VERNEED 0000000000003000 003000
000030 00 A 36 1 8
[ 5] .rela.dyn RELA 0000000000003030 003030
000528 18 A 2 0 8
[ 6] .rela.plt RELA 0000000000003558 003558
000c78 18 A 2 8 8
[ 7] .init PROGBITS 00000000000041d0 0041d0
000018 00 AX 0 0 4
[ 8] .plt PROGBITS 00000000000041e8 0041e8
000860 10 AX 0 0 4
[ 9] .text PROGBITS 0000000000004a50 004a50
006578 00 AX 0 0 16
[10] .fini PROGBITS 000000000000afc8 00afc8
00000e 00 AX 0 0 4
[11] .rodata PROGBITS 000000000000afe0 00afe0
000e77 00 A 0 0 32
[12] .eh_frame_hdr PROGBITS 000000000000be58 00be58
00047c 00 A 0 0 4
[13] .eh_frame PROGBITS 000000000000c2d8 00c2d8
000ffc 00 A 0 0 8
[14] .ctors PROGBITS 000000000010d2d8 00d2d8
000010 00 WA 0 0 8
[15] .dtors PROGBITS 000000000010d2e8 00d2e8
000010 00 WA 0 0 8
[16] .jcr PROGBITS 000000000010d2f8 00d2f8
000008 00 WA 0 0 8
[17] .data.rel.ro PROGBITS 000000000010d300 00d300
000058 00 WA 0 0 8
[18] .got PROGBITS 000000000010d508 00d508
000140 08 WA 0 0 8
[19] .got.plt PROGBITS 000000000010d648 00d648
000440 08 WA 0 0 8
[20] .data PROGBITS 000000000010da88 00da88
000030 00 WA 0 0 8
[21] .bss NOBITS 000000000010dab8 00dab8
0000a0 00 WA 0 0 8
[22] .comment PROGBITS 0000000000000000 00dab8
0002b0 00 0 0 1
[23] .debug_aranges PROGBITS 0000000000000000 00dd68
0001e0 00 0 0 1
[24] .debug_pubnames PROGBITS 0000000000000000 00df48
001174 00 0 0 1
[25] .debug_info PROGBITS 0000000000000000 00f0bc
007bad 00 0 0 1
[26] .debug_abbrev PROGBITS 0000000000000000 016c69
001420 00 0 0 1
[27] .debug_line PROGBITS 0000000000000000 018089
001d0c 00 0 0 1
[28] .debug_frame PROGBITS 0000000000000000 019d98
0013c0 00 0 0 8
[29] .debug_str PROGBITS 0000000000000000 01b158
001cec 01 MS 0 0 1
[30] .debug_loc PROGBITS 0000000000000000 01ce44
00ace9 00 0 0 1
[31] .debug_ranges PROGBITS 0000000000000000 027b2d
000960 00 0 0 1
[32] .shstrtab STRTAB 0000000000000000 02848d
000154 00 0 0 1
[33] .symtab SYMTAB 0000000000000000 028f28
001ec0 18 34 98 8
[34] .strtab STRTAB 0000000000000000 02ade8
0014f3 00 0 0 1
[35] .dynamic DYNAMIC 000000000010e150 02d150
0001c0 10 WA 36 0 8
[36] .dynstr STRTAB 000000000010e310 02d310
000f1e 00 A 0 0 8
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD 0x000000 0x0000000000000000 0x0000000000000000
0x00d2d4 0x00d2d4 R E 0x100000
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000
0x000000 0x000000 RW 0x8
GNU_EH_FRAME 0x00be58 0x000000000000be58 0x000000000000be58
0x00047c 0x00047c R 0x4
LOAD 0x00d2d8 0x000000000010d2d8 0x000000000010d2d8
0x0007e0 0x000880 RW 0x100000
LOAD 0x02d000 0x000000000010e000 0x000000000010e000
0x001230 0x001230 RW 0x1000
DYNAMIC 0x02d150 0x000000000010e150 0x000000000010e150
0x0001c0 0x0001c0 RW 0x8
Segment Sections...
00 .hash .dynsym .gnu.version .gnu.version_r .rela.dyn
.rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
01
02 .eh_frame_hdr
03 .ctors .dtors .jcr .data.rel.ro .got .got.plt .data .bss
04 .dynamic
05 .dynamic
_______________________________________________
nix-dev mailing list
https://mail.cs.uu.nl/mailman/listinfo/nix-dev
Tim Crowder
2010-05-06 16:31:53 UTC
Permalink
Yes, ldconfig is the only thing I've seen complain so far.
Executables that I've tried work against it.
readelf, objdump, nm, ldd, ... seem happy with it.

I have a bit more info now. The LOAD entry that patchelf
creates has 4k page alignment, but the others are all 1M.
And so, the file offset and physical/virtual only line up
modulo 4k. If I pad the file with junk out to the place they'd
line up modulo 1M, then ldconfig is happy. A bit shorter and
it complains. But of course, I don't want the library to be 10x
the size it needs.

Anyways, it seems like ldconfig is either assuming that those
pages all load with the same alignment, or worse, all load with 1M
alignment. I haven't seen anything in the ELF spec that requires
this though.

Any thoughts on how to work around this?

Thanks!

-timrc
Post by Lluís Batlle i Rossell
I used patchelf with x86_64 libraries, but I did not use ldconfig with them.
For what I tried, all worked.
Do those x86_64 libraries patchelf'ed fail *only* according to ldconfig?
Post by Tim Crowder
I'm using patchelf to add rpath to some libraries, both 32 and 64-bit.
They both seem to work with executables, but ldconfig complains
/sbin/ldconfig: file ./liblwes64.so is truncated
I've looked at the section offsets and sizes, etc, and I didn't yet
find anything that
points past the end-of-file. Also, readelf hasn't complained about anything.
I'm including the file listing and some readelf output.
Any idea what might be wrong?
Let me know if there's any other info I can provide...
Thanks!
-timrc
=================================================================================
-rwxr-xr-x 1 crowdert 188976 May 4 17:19 liblwes64.so
[~/work/pst/lwes/tmp/rpath]
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x4a50
Start of program headers: 184320 (bytes into file)
Start of section headers: 165352 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 6
Size of section headers: 64 (bytes)
Number of section headers: 37
Section header string table index: 32
[Nr] Name Type Address Off
Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000
000000 00 0 0 0
[ 1] .hash HASH 0000000000000158 000158
0006e8 04 A 2 0 8
[ 2] .dynsym DYNSYM 0000000000000840 000840
0016c8 18 A 36 13 8
[ 3] .gnu.version VERSYM 0000000000002e18 002e18
0001e6 02 A 2 0 2
[ 4] .gnu.version_r VERNEED 0000000000003000 003000
000030 00 A 36 1 8
[ 5] .rela.dyn RELA 0000000000003030 003030
000528 18 A 2 0 8
[ 6] .rela.plt RELA 0000000000003558 003558
000c78 18 A 2 8 8
[ 7] .init PROGBITS 00000000000041d0 0041d0
000018 00 AX 0 0 4
[ 8] .plt PROGBITS 00000000000041e8 0041e8
000860 10 AX 0 0 4
[ 9] .text PROGBITS 0000000000004a50 004a50
006578 00 AX 0 0 16
[10] .fini PROGBITS 000000000000afc8 00afc8
00000e 00 AX 0 0 4
[11] .rodata PROGBITS 000000000000afe0 00afe0
000e77 00 A 0 0 32
[12] .eh_frame_hdr PROGBITS 000000000000be58 00be58
00047c 00 A 0 0 4
[13] .eh_frame PROGBITS 000000000000c2d8 00c2d8
000ffc 00 A 0 0 8
[14] .ctors PROGBITS 000000000010d2d8 00d2d8
000010 00 WA 0 0 8
[15] .dtors PROGBITS 000000000010d2e8 00d2e8
000010 00 WA 0 0 8
[16] .jcr PROGBITS 000000000010d2f8 00d2f8
000008 00 WA 0 0 8
[17] .data.rel.ro PROGBITS 000000000010d300 00d300
000058 00 WA 0 0 8
[18] .got PROGBITS 000000000010d508 00d508
000140 08 WA 0 0 8
[19] .got.plt PROGBITS 000000000010d648 00d648
000440 08 WA 0 0 8
[20] .data PROGBITS 000000000010da88 00da88
000030 00 WA 0 0 8
[21] .bss NOBITS 000000000010dab8 00dab8
0000a0 00 WA 0 0 8
[22] .comment PROGBITS 0000000000000000 00dab8
0002b0 00 0 0 1
[23] .debug_aranges PROGBITS 0000000000000000 00dd68
0001e0 00 0 0 1
[24] .debug_pubnames PROGBITS 0000000000000000 00df48
001174 00 0 0 1
[25] .debug_info PROGBITS 0000000000000000 00f0bc
007bad 00 0 0 1
[26] .debug_abbrev PROGBITS 0000000000000000 016c69
001420 00 0 0 1
[27] .debug_line PROGBITS 0000000000000000 018089
001d0c 00 0 0 1
[28] .debug_frame PROGBITS 0000000000000000 019d98
0013c0 00 0 0 8
[29] .debug_str PROGBITS 0000000000000000 01b158
001cec 01 MS 0 0 1
[30] .debug_loc PROGBITS 0000000000000000 01ce44
00ace9 00 0 0 1
[31] .debug_ranges PROGBITS 0000000000000000 027b2d
000960 00 0 0 1
[32] .shstrtab STRTAB 0000000000000000 02848d
000154 00 0 0 1
[33] .symtab SYMTAB 0000000000000000 028f28
001ec0 18 34 98 8
[34] .strtab STRTAB 0000000000000000 02ade8
0014f3 00 0 0 1
[35] .dynamic DYNAMIC 000000000010e150 02d150
0001c0 10 WA 36 0 8
[36] .dynstr STRTAB 000000000010e310 02d310
000f1e 00 A 0 0 8
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD 0x000000 0x0000000000000000 0x0000000000000000
0x00d2d4 0x00d2d4 R E 0x100000
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000
0x000000 0x000000 RW 0x8
GNU_EH_FRAME 0x00be58 0x000000000000be58 0x000000000000be58
0x00047c 0x00047c R 0x4
LOAD 0x00d2d8 0x000000000010d2d8 0x000000000010d2d8
0x0007e0 0x000880 RW 0x100000
LOAD 0x02d000 0x000000000010e000 0x000000000010e000
0x001230 0x001230 RW 0x1000
DYNAMIC 0x02d150 0x000000000010e150 0x000000000010e150
0x0001c0 0x0001c0 RW 0x8
Segment Sections...
00 .hash .dynsym .gnu.version .gnu.version_r .rela.dyn
.rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame
01
02 .eh_frame_hdr
03 .ctors .dtors .jcr .data.rel.ro .got .got.plt .data .bss
04 .dynamic
05 .dynamic
_______________________________________________
nix-dev mailing list
https://mail.cs.uu.nl/mailman/listinfo/nix-dev
Loading...