[m-rev.] for review: fix GNU ld warning about executable stack
Julien Fischer
jfischer at opturion.com
Fri Apr 4 17:46:30 AEDT 2025
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?
...
> diff --git a/configure.ac b/configure.ac
> index f8469a441..be3094824 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2,7 +2,7 @@
> # vim: ts=4 sw=4 expandtab
> #-----------------------------------------------------------------------------#
> # Copyright (C) 1995-2012 The University of Melbourne.
> -# Copyright (C) 2013-2024 The Mercury team.
> +# Copyright (C) 2013-2025 The Mercury team.
> # This file may only be copied under the terms of the GNU General
> # Public Licence - see the file COPYING in the Mercury distribution.
> #-----------------------------------------------------------------------------#
> @@ -2977,6 +2977,8 @@ ENABLE_BOEHM_PARALLEL_MARK=
> #
> BOEHM_CFLAGS_FOR_THREADS="-DGC_THREADS"
>
> +BOEHM_NEED_ATOMIC_OPS_ASM=no
> +
> # This should be set if both the system malloc and Boehm GC (in the default
> # configuration) may both call sbrk.
> avoid_sbrk=
> @@ -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.
That's fine otherwise.
Julien.
More information about the reviews
mailing list