stack usage with libgcc math funcs
i dont know superh assembly, so i cant really check the code myself. starting with at gcc-4.1.2 (at least, gcc-3.4.6 doesnt seem to have this issue), a few objects in libgcc.a lack GNU-stack markings. here is the scanelf output against libgcc.a from gcc-4.3.2. basically, '!WX' just means that the objects do not have a .note.GNU-stack section.
$ scanelf -qeR . !WX --- --- ./4.3.2/_ashiftrt.o !WX --- --- ./4.3.2/_ashiftrt_n.o !WX --- --- ./4.3.2/_ashiftlt.o !WX --- --- ./4.3.2/_lshiftrt.o !WX --- --- ./4.3.2/_movmem.o !WX --- --- ./4.3.2/_movmem_i4.o !WX --- --- ./4.3.2/_mulsi3.o !WX --- --- ./4.3.2/_sdivsi3.o !WX --- --- ./4.3.2/_sdivsi3_i4.o !WX --- --- ./4.3.2/_udivsi3.o !WX --- --- ./4.3.2/_udivsi3_i4.o !WX --- --- ./4.3.2/_set_fpscr.o !WX --- --- ./4.3.2/_div_table.o !WX --- --- ./4.3.2/_udiv_qrnnd_16.o !WX --- --- ./4.3.2/_ic_invalidate.o !WX --- --- ./4.3.2/_ic_invalidate_array.o !WX --- --- ./4.3.2/linux-atomic.o
assuming libgcc doesnt actually use the stack to exec code, the attached patch should fix things i think.
-mike
config/sh/lib1funcs.asm +5 -0
@@ -34,6 +34,11 @@ !! recoded in assembly by Toshiyasu Morita !! [email protected] +#if defined(__ELF__) && defined(__linux__) +.section .note.GNU-stack,"",%progbits +.previous +#endif + /* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and ELF local label prefixes by J"orn Rennecke [email protected] */
and linux-atomic.asm needs a similar change
config/sh/linux-atomic.asm +5 -0
@@ -138,3 +138,8 @@ ATOMIC_FETCH_AND_COMBOP(nand,and,not,4,l,mov) #endif /* ! __SH5__ */ + +#if defined(__ELF__) && defined(__linux__) +.section .note.GNU-stack,"",%progbits +.previous +#endif
as a note, without these changes, the execstack markings bubble up into some of the glibc libs as those are built with -static-libgcc ... i can see this with glibc-2.9 for sure.
-mike
Quoted 7 lines · Mike Frysinger
i dont know superh assembly, so i cant really check the code myself. starting with at gcc-4.1.2 (at least, gcc-3.4.6 doesnt seem to have this issue), a few objects in libgcc.a lack GNU-stack markings. here is the scanelf output against libgcc.a from gcc-4.3.2. basically, '!WX' just means that the objects do not have a .note.GNU-stack section.
assuming libgcc doesnt actually use the stack to exec code, the attached patch should fix things i think.
Thanks for pointing this out. Could you please send your patches to gcc-patches or file this issue to gcc bugzilla? Unfortunately, now gcc trunk is in stage 4 and any patches for non strict regressions can't be accepted temporary. I'll schedule these patches for 4.5, then apply them to the open branches after 4.5.
Thanks,
kaz
Quoted 10 lines · On Wednesday 24 December 2008 17:57:53 Kaz Kojima wrote:
Quoted 7 lines · Mike Frysinger
i dont know superh assembly, so i cant really check the code myself. starting with at gcc-4.1.2 (at least, gcc-3.4.6 doesnt seem to have this issue), a few objects in libgcc.a lack GNU-stack markings. here is the scanelf output against libgcc.a from gcc-4.3.2. basically, '!WX' just means that the objects do not have a .note.GNU-stack section. assuming libgcc doesnt actually use the stack to exec code, the attached patch should fix things i think.
Thanks for pointing this out.
i'm guessing that means they're correct :)
Quoted 2 lines
Could you please send your
patches to gcc-patches or file this issue to gcc bugzilla?
i dont think people like it when i post patches to bugzilla. they tell me to use gcc-patches.
Quoted 4 lines
Unfortunately, now gcc trunk is in stage 4 and any patches for non strict regressions can't be accepted temporary. I'll schedule these patches for 4.5, then apply them to the open branches after 4.5.
well, i would say this is a long standing regression. gcc-3.4.6 does not result in exec stacks with any of the libgcc.a math functions ... but you're the gcc expert.
-mike
Quoted 3 lines · Mike Frysinger
well, i would say this is a long standing regression. gcc-3.4.6 does not result in exec stacks with any of the libgcc.a math functions ... but you're the gcc expert.
.note.GNU-stack wasn't used in gcc-3.4 era. This type of problem wouldn't be a "strict" regression, from the compiler's viewpoint.
Regards,
kaz