#6 Allow Fortran examples to have an executable stack
Merged 3 months ago by orion. Opened 3 months ago by jjames.
rpms/ jjames/plplot rawhide  into  rawhide

file modified
+5 -4
@@ -65,7 +65,7 @@ 

  

  Name:           plplot

  Version:        5.15.0

- Release:        63%{?dist}

+ Release:        64%{?dist}

  Summary:        Library of functions for making scientific plots

  

  License:        LGPLv2+
@@ -417,9 +417,7 @@ 

  

  

  %build

- export CFLAGS="$RPM_OPT_FLAGS"

- export CXXFLAGS="$RPM_OPT_FLAGS"

- export FFLAGS="$RPM_OPT_FLAGS"

+ export LDFLAGS='%{build_ldflags} -Wl,--no-warn-execstack'

  export PATH="%{_qt5_bindir}:$PATH"

  # Needed for octave output to not have control characters

  unset TERM
@@ -774,6 +772,9 @@ 

  

  

  %changelog

+ * Wed Mar 20 2024 Jerry James <loganjerry@gmail.com> - 5.15.0-64

+ - Allow Fortran examples to have an executable stack

+ 

  * Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 5.15.0-63

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

  

Remove the explicit C, C++, and Fortran flags settings, as those are redundant. They are automatically set at the top of %build. Furthermore, they force all 3 compilers to use the same flags; the desired flags may diverge in the future.

Add -Wl,--no-warn-execstack to not complain about the Fortran examples that use an executable stack. Alternatives:
- Add -Wl,-z,noexecstack so that an executable stack cannot be used. Then the Fortran examples that do use it segfault during testing.
- Add -Wl,--no-error-execstack; something turns the warning into an error anyway, so the build fails. I haven't tried to track this down.

You could complement this with -Wtrampolines to help you find which parts of the code need an executable stack.

Pull-Request has been merged by orion

3 months ago

Thank you for this. I'll see if I can figure out more about is triggering the executable stack.

/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xtraditional09a.adb:92:5: warning: trampoline generated for nested function ‘xtraditional09a.mypltr’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xstandard09a.adb:92:5: warning: trampoline generated for nested function ‘xstandard09a.mypltr’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xtraditional14a.adb:258:9: warning: trampoline generated for nested function ‘xtraditional14a.plot5.mypltr’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xstandard14a.adb:258:9: warning: trampoline generated for nested function ‘xstandard14a.plot5.mypltr’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xtraditional16a.adb:103:5: warning: trampoline generated for nested function ‘xtraditional16a.zdefined’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xstandard16a.adb:103:5: warning: trampoline generated for nested function ‘xstandard16a.zdefined’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xtraditional19a.adb:68:5: warning: trampoline generated for nested function ‘xtraditional19a.map_transform’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xtraditional19a.adb:97:5: warning: trampoline generated for nested function ‘xtraditional19a.mapform19’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xtraditional19a.adb:124:5: warning: trampoline generated for nested function ‘xtraditional19a.geolocation_labeler’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xstandard19a.adb:68:5: warning: trampoline generated for nested function ‘xstandard19a.map_transform’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xstandard19a.adb:97:5: warning: trampoline generated for nested function ‘xstandard19a.mapform19’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xstandard19a.adb:124:5: warning: trampoline generated for nested function ‘xstandard19a.geolocation_labeler’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xtraditional22a.adb:140:5: warning: trampoline generated for nested function ‘xtraditional22a.transform’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/ada/xstandard22a.adb:140:5: warning: trampoline generated for nested function ‘xstandard22a.transform’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/fortran/x09f.f90:187:21: warning: trampoline generated for nested function ‘mypltr.3’ [-Wtrampolines]
/home/orion/fedora/plplot/plplot-5.15.0/examples/fortran/x09f.f90:187:21: warning: trampoline generated for nested function ‘mypltr’ [-Wtrampolines]

All of those cases look like pointers to nested subroutines being passed as callback parameters to C functions. That's probably the most common remaining situation where GCC still needs trampolines. Nested procedures and functions are perfectly normal in Ada (maybe in Fortran too?), but I guess some trickery is needed to make them callable from C code.

If those are just example programs, then I think those cases are nothing to worry about. If programmers using PLplot want their programs hardened against stack-based buffer overflow attacks, then they'll have to write their callback routines outside of other subroutines, unless and until GCC becomes able to compile such cases without trampolines.

I added -Wtrampolines to build_adaflags a while ago to help us find these cases in Ada code.

Metadata