[PATCHv2] Handle not explicitly zero terminated strings in merge sections
Rainer Orth
ro@CeBiTec.Uni-Bielefeld.DE
Wed Oct 10 12:23:00 GMT 2018
Hi Eric,
>> Which version exactly (pkg list entire) of Solaris 11 are you running?
>> I'm using gas 2.31 and /bin/ld on Solaris 11.4 resp. 11.5 Beta, where
>> Bernd's patch in PR bootstrap/87551 fixed the remaining regressions.
>
> Solaris 11.3 with Gas 2.30.
I could now reproduce the regressions on Solaris 11.3 SRU 35.6 (the
latest and last 11.3 update), e.g.
+FAIL: gfortran.dg/allocatable_function_5.f90 -O1 execution test
Program received signal SIGBUS: Access to an undefined portion of a memory object.
Backtrace for this error:
Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x00010fe0 in foo (_carg=12, carg=..., .__result=0x215d4 <slen.0>,
__result=<optimized out>)
at /vol/gcc/src/hg/trunk/local/gcc/testsuite/gfortran.dg/allocatable_function_5.f90:41
41 res = carg(1:3)
(gdb) where
#0 0x00010fe0 in foo (_carg=12, carg=..., .__result=0x215d4 <slen.0>,
__result=<optimized out>)
at /vol/gcc/src/hg/trunk/local/gcc/testsuite/gfortran.dg/allocatable_function_5.f90:41
#1 MAIN__ ()
at /vol/gcc/src/hg/trunk/local/gcc/testsuite/gfortran.dg/allocatable_function_5.f90:22
1: x/i $pc
=> 0x10fe0 <MAIN__+24>: lduh [ %g1 + 0x3a9 ], %g1
(gdb) p/x $g1
$1 = 0x10800
(gdb) x/7i MAIN__
0x10fc8 <MAIN__>: save %sp, -104, %sp
0x10fcc <MAIN__+4>: call 0x213c4 <malloc@got.plt>
0x10fd0 <MAIN__+8>: mov 3, %o0
0x10fd4 <MAIN__+12>: mov %o0, %i5
0x10fd8 <MAIN__+16>: sethi %hi(0x10800), %g1
0x10fdc <MAIN__+20>: or %g1, 0x3a9, %g2 ! 0x10ba9
=> 0x10fe0 <MAIN__+24>: lduh [ %g1 + 0x3a9 ], %g1
(gdb) x/s 0x10800+0x3a9
0x10ba9: 'foo calling \000'
Looking at the .rodata.str1.4 section, I see
$ objdump -s -j .rodata.str1.8 allocatable_function_5.exe
allocatable_function_5.exe: file format elf32-sparc-sol2
Contents of section .rodata.str1.8:
10ba8 6d666f6f 2063616c 6c696e67 20000000 mfoo calling ...
10bb8 666f6f00 00000000 6c687300 00000000 foo.....lhs.....
This string table compression can be disabled with ld -z nocomprstrtab:
-z nocompstrtab
Disables the compression of ELF string tables, and comment sec-
tions. By default, string compression is applied to SHT_STRTAB sec-
tions, to SHT_PROGBITS sections that have their SHF_MERGE and
SHF_STRINGS section flags set, and to comment sections.
This isn't necessary on Solaris 11.4, and Solaris 11.3/x86 isn't
affected as well. I'm still determining what the best course of action
is: disable string merging support before Solaris 11.4 or enable the
workaround above instead.
sparc-sun-solaris2.11 and i386-pc-solaris2.11 bootstraps with
LD_OPTIONS='-z nocompstrtab' are currently running to check if this
fixes all regressions.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
More information about the Gcc-patches
mailing list