[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/19162] Huge binary after linking sections with "a" and "wa" flag
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/19162] Huge binary after linking sections with "a" and "wa" flags |
Date: |
Thu, 22 Oct 2015 09:53:08 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=19162
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |WONTFIX
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Ilya Verbin from comment #0)
> The testcase:
>
> $ cat t1.s
> .section ".AAA", "a"
> .long 0x12345678
> $ cat t2.s
> .section ".AAA", "wa"
> .long 0x12345678
> $ as t1.s -o t1.o
> $ as t2.s -o t2.o
> $ ld -shared t1.o t2.o
> $ ls -lh a.out
> 2.1M a.out
>
> Some strange 2MB offset is inserted into another section:
>
> [Nr] Name Type Address Offset
> Size EntSize Flags Link Info Align
> [ 0] NULL 0000000000000000 00000000
> 0000000000000000 0000000000000000 0 0 0
> [ 1] .hash HASH 00000000000000b0 000000b0
> 0000000000000028 0000000000000004 A 2 0 8
> [ 2] .dynsym DYNSYM 00000000000000d8 000000d8
> 0000000000000078 0000000000000018 A 3 2 8
> [ 3] .dynstr STRTAB 0000000000000150 00000150
> 0000000000000019 0000000000000000 A 0 0 1
> [ 4] .AAA PROGBITS 0000000000000169 00000169
> 0000000000000008 0000000000000000 WA 0 0 1
> [ 5] .eh_frame PROGBITS 0000000000000178 00000178
> 0000000000000000 0000000000000000 A 0 0 8
> [ 6] .dynamic DYNAMIC 0000000000200178 00200178 <-- ???
> 00000000000000b0 0000000000000010 WA 3 0 8
>
> It seems that something goes wrong during section-to-segment mapping,
> because when both .AAA have "wa" flags, we got small binary with 2 LOAD
> segments:
> Type Offset VirtAddr PhysAddr
> FileSiz MemSiz Flags Align
> LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
> 0x00000000000001a8 0x00000000000001a8 R 200000
> LOAD 0x00000000000001a8 0x00000000002001a8 0x00000000002001a8
> 0x00000000000000b8 0x00000000000000b8 RW 200000
>
> But when one .AAA has "a" flag, and another .AAA has "wa" flag, we got huge
> binary with only one big LOAD segment:
> Type Offset VirtAddr PhysAddr
> FileSiz MemSiz Flags Align
> LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
> 0x0000000000200228 0x0000000000200228 RW 200000
Since ld defaults to 2MB maximum page size, it is normal:
address@hidden pr19162]$ make clean
rm -f *.o *.so *.a
address@hidden pr19162]$ make
gcc -fPIC -O2 -c -o t1.o t1.s
gcc -fPIC -O2 -c -o t2.o t2.s
./ld -shared -o x.so t1.o t2.o
ls -lh x.so
-rwxrwxr-x 1 hjl hjl 2.1M Oct 22 08:22 x.so
address@hidden pr19162]$ make clean
rm -f *.o *.so *.a
address@hidden pr19162]$ make LDFLAGS="-z max-page-size=0x1000"
gcc -fPIC -O2 -c -o t1.o t1.s
gcc -fPIC -O2 -c -o t2.o t2.s
./ld -shared -z max-page-size=0x1000 -o x.so t1.o t2.o
ls -lh x.so
-rwxrwxr-x 1 hjl hjl 5.6K Oct 22 08:22 x.so
address@hidden pr19162]$
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/19162] New: Huge binary after linking sections with "a" and "wa" flags, iverbin at gmail dot com, 2015/10/22
- [Bug ld/19162] Huge binary after linking sections with "a" and "wa" flags,
hjl.tools at gmail dot com <=
- [Bug ld/19162] Huge binary after linking sections with "a" and "wa" flags, hjl.tools at gmail dot com, 2015/10/22
- [Bug ld/19162] Huge binary after linking sections with "a" and "wa" flags, amodra at gmail dot com, 2015/10/28
- [Bug ld/19162] Huge binary after linking sections with "a" and "wa" flags, amodra at gmail dot com, 2015/10/28
- [Bug ld/19162] Huge binary after linking sections with "a" and "wa" flags, cvs-commit at gcc dot gnu.org, 2015/10/28
- [Bug ld/19162] Huge binary after linking sections with "a" and "wa" flags, amodra at gmail dot com, 2015/10/28
- [Bug ld/19162] Huge binary after linking sections with "a" and "wa" flags, cvs-commit at gcc dot gnu.org, 2015/10/28
- [Bug ld/19162] Huge binary after linking sections with "a" and "wa" flags, cvs-commit at gcc dot gnu.org, 2015/10/29