You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Put large common blocks into .lbss for the medium and large code models
For the medium and large code models on x86-64, the bss is split into two parts,
.bss for regular sized data, and .lbss for data larger than that specified by
-large-data-threshold (for the medium code model). This change tries to mimick
what gcc does for the medium and large code models for Fortran COMMON blocks:
program test
implicit integer (i-n)
implicit real*8 (a-h, o-z)
parameter (n1=77777, n2=77777)
common v2(n1,n2)
common /ccc/ v6
v6 = 1
v2(6777,6777) = 2
write (*,*) v6, v2(6777, 6777)
end program test
Currently, we generate:
0000000000000008 O *COM* 0000000000000008 ccc_
0000000b44834508 O *COM* 0000000000000008 __BLNK
and ld and lld both fail to link with -mcmodel=medium.
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
or
ld.lld: error: /usr/lib/gcc/x86_64-redhat-linux/11/crtbeginS.o:(.text+0x76): relocation R_X86_64_PC32 out of range: 48394103061 is not in [-2147483648, 2147483647]; references section '.bss'
With this change, __BLNK is marked as LARGE_COMMON (SHN_AMD64_LCOMMON),
and ends up in .lbss.
*.o:
Sections:
...
1 .lbss 00000000 0000000000000000 0000000000000000 000000fb 2**0
ALLOC
...
SYMBOL TABLE:
0000000000000008 O *COM* 0000000000000008 ccc_
0000000b44834508 O LARGE_COMMON 0000000000000008 __BLNK__
a.out:
Sections:
...
25 .bss 00000009 0000000000003cf0 0000000000003cf0 00000cf0 2**3
ALLOC
26 .lbss b44834508 0000000000003d00 0000000000003d00 00000cf0 2**3
ALLOC
SYMBOL TABLE:
0000000000003cf0 g O .bss 0000000000000008 ccc_
0000000000003d00 g O .lbss 0000000b44834508 __BLNK__
In the assembly, this will appear as:
.section .lbss,"awl",@nobits
.type __BLNK__,@object
.largecomm __BLNK__,48394093832,8
.type ccc_,@object
.comm ccc_,8,8
For the large code model, all common blocks will end up in lbss.
Previously, the above example wouldn't link statically with GNU ld.
The change also includes support for parsing the largecomm directive.
There will be a PR for the chages to lld to handle the SHN_AMD64_LCOMMON
section.
0 commit comments