[m-rev.] for review: fix GNU ld warning about executable stack
Peter Wang
novalazy at gmail.com
Mon Apr 7 15:24:21 AEST 2025
On Fri, 04 Apr 2025 17:46:30 +1100 Julien Fischer <jfischer at opturion.com> wrote:
> Hi Peter,
>
> On Fri, 4 Apr 2025 at 11:48, Peter Wang <novalazy at gmail.com> wrote:
> >
> > The first change is for our fork of bdwgc.
> > The second change is in the mercury repository.
> >
> > -------------------
> >
> > Add var to control inclusion of atomic_ops_sysdeps.o
> >
> > Makefile.direct:
> > Only include atomic_ops_sysdeps.o in OBJS if enabled
> > by a variable BOEHM_NEED_ATOMIC_OPS_ASM.
> >
> > diff --git a/Makefile.direct b/Makefile.direct
> > index 40c768c3..3ea4ee49 100644
> > --- a/Makefile.direct
> > +++ b/Makefile.direct
> > @@ -144,7 +144,18 @@ OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o \
> > malloc.o checksums.o pthread_support.o pthread_stop_world.o \
> > darwin_stop_world.o typd_mlc.o ptr_chck.o mallocx.o gcj_mlc.o specific.o \
> > gc_dlopen.o backgraph.o win32_threads.o pthread_start.o \
> > - thread_local_alloc.o fnlz_mlc.o atomic_ops.o atomic_ops_sysdeps.o
> > + thread_local_alloc.o fnlz_mlc.o atomic_ops.o
> > +
> > +# Mercury-specific: atomic_ops_sysdeps.o will be empty (devoid of sections)
> > +# except when targeting Solaris/SPARC with a compiler other than GCC.
> > +# If the empty object file is linked in, GNU ld will treat the executable or
> > +# shared library as requiring an executable stack, and newer versions of GNU ld
> > +# will warn that "missing .note.GNU-stack section implies executable stack".
> > +# Therefore, we allow atomic_ops_sysdeps.o to be omitted from OBJS
> > +# when not required, which is usually the case.
> > +ifeq ($(BOEHM_NEED_ATOMIC_OPS_ASM),yes)
> > +OBJS+= atomic_ops_sysdeps.o
> > +endif
> >
> > CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c \
> > headers.c mark.c obj_map.c blacklst.c finalize.c \
>
> Do you know if this is an issue with upstream Boehm?
>
I think upstream mostly expects users to use the other build systems
(autotools or CMake), which will detect if atomic_ops_sysdeps.o is
required.
For Makefile.direct, the upstream master branch actually moves
atomic_ops_sysdeps.o into a separate list named NODIST_OBJS,
which doesn't get included into the static libgc.a.
https://github.com/ivmai/bdwgc/blob/cc0e47485ce23c7cdc5ca219f234facca73a514b/Makefile.direct#L119
NODIST_OBJS *is* used in the rules to build test progams, and to build
shared libraries. I'm not sure if anyone has thought about the shared
library targets in a while; I'll ask upstream.
> > @@ -2987,6 +2989,13 @@ case "$host" in
> > THREAD_LIBS="-lpthread -lrt -ldl"
> > ENABLE_BOEHM_THREAD_LOCAL_ALLOC="-DTHREAD_LOCAL_ALLOC"
> > ENABLE_BOEHM_PARALLEL_MARK="-DPARALLEL_MARK"
> > + case "$host" in
> > + sparc*)
> > + if test "$mercury_cv_cc_type" != gcc; then
> > + BOEHM_NEED_ATOMIC_OPS_ASM=yes
> > + fi
> > + ;;
> > + esac
>
> It's probably worth adding a pointer to the explanation in
> boehm_gc/Makefile.direct there.
>
Done, thanks.
Peter
More information about the reviews
mailing list