# Ld error 'missing .note.GNU-stack section'

**URL:** <https://discuss.ocaml.org/t/ld-error-missing-note-gnu-stack-section/12478>\
**Category:** Community\
**Tags:** freebsd, dune\
**Created:** [June 26, 2023, 9:32am UTC](https://discuss.ocaml.org/t/ld-error-missing-note-gnu-stack-section/12478 "2023-06-26T09:32:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mro](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mro/32/2496_2.png) [@mro](https://discuss.ocaml.org/u/mro)\
**Post date:** [June 26, 2023, 9:32am UTC](https://discuss.ocaml.org/t/ld-error-missing-note-gnu-stack-section/12478/1 "2023-06-26T09:32:04Z")

</div>

when running `$ dune build` e.g. on project [geohash](https://codeberg.org/mro/geohash) I get:

```auto
$ dune build
/usr/local/bin/ld: warning: lib__Cgi.o: missing .note.GNU-stack section implies executable stack
/usr/local/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/local/bin/ld: warning: geohash.o: missing .note.GNU-stack section implies executable stack
/usr/local/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/local/bin/ld: warning: amd64.o: missing .note.GNU-stack section implies executable stack
/usr/local/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/local/bin/ld: warning: amd64.o: missing .note.GNU-stack section implies executable stack
/usr/local/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/local/bin/ld: warning: amd64.o: missing .note.GNU-stack section implies executable stack
/usr/local/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/local/bin/ld: warning: amd64.o: missing .note.GNU-stack section implies executable stack
/usr/local/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

```

It’s on a newly installed [FreeBSD 13.2 on a Thinkpad (x250)](https://codeberg.org/mro/x250-freebsd).

```auto
$ ld --version
LLD 14.0.5 (FreeBSD llvmorg-14.0.5-0-gc12386ae247c-1400004) (compatible with GNU linkers)
$ dune --version
3.8.2
$ opam switch
# switch compiler description
→ 4.11.2 ocaml-base-compiler.4.11.2 4.11.2

```

How can I get rid of this annoyance?

---

<div class="post-metadata">

**Author:** ![octachron](https://avatars.discourse-cdn.com/v4/letter/o/49beb7/32.png) [@octachron](https://discuss.ocaml.org/u/octachron)\
**Post date:** [June 27, 2023, 9:00am UTC](https://discuss.ocaml.org/t/ld-error-missing-note-gnu-stack-section/12478/2 "2023-06-27T09:00:11Z")

</div>

There is something strange going on: the lld linker ignores `note.GNU-stack` as a policy, and the warning that you see is a BFD warning.

Anyway, you should be able to silence those warnings by adding ~~`-z noexecflags`~~ `-z noexecstack` to the linker flags.

---

<div class="post-metadata">

**Author:** ![mro](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mro/32/2496_2.png) [@mro](https://discuss.ocaml.org/u/mro)\
**Post date:** [June 27, 2023, 10:51am UTC](https://discuss.ocaml.org/t/ld-error-missing-note-gnu-stack-section/12478/3 "2023-06-27T10:51:28Z")

</div>

> [@octachron](#):
>
> `noexecflags`

@octachron thanks for helping me, sadly I don’t know how to do that. [Stanza Reference — Dune documentation](https://dune.readthedocs.io/en/stable/dune-files.html#shared-exe-fields) was not helpful.

When I do this [unsuccessfully trying to add linker flags. · e7a0274735 - geohash - Codeberg.org](https://codeberg.org/mro/geohash/commit/e7a0274735e6cc2bdc6111aab806bff2d0c32c83) there is no effect. I tried a dozend variations and spent almost an hour.

Where do I have to put what?

---

<div class="post-metadata">

**Author:** ![octachron](https://avatars.discourse-cdn.com/v4/letter/o/49beb7/32.png) [@octachron](https://discuss.ocaml.org/u/octachron)\
**Post date:** [June 27, 2023, 11:44am UTC](https://discuss.ocaml.org/t/ld-error-missing-note-gnu-stack-section/12478/4 "2023-06-27T11:44:24Z")

</div>

Using the correct name (sorry for the mistake) with

```ocaml
(flags (:standard -cclib "-z noexecstack"))

```

should work. Nevertheless, it is probably a good idea ti check that the option is recognized with the linker by building in verbose mode:

```ocaml
dune build --verbose

```

---

<div class="post-metadata">

**Author:** ![mro](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mro/32/2496_2.png) [@mro](https://discuss.ocaml.org/u/mro)\
**Post date:** [June 27, 2023, 1:23pm UTC](https://discuss.ocaml.org/t/ld-error-missing-note-gnu-stack-section/12478/5 "2023-06-27T13:23:37Z")

</div>

Thanks @octachron, never would have figured that out alone.

I had to combine `flags`with the previously existing `link_flags` and finally succeeded at [silence the linker warning '.. missing .note.GNU-stack section ..' · 0a32c16b1b - geohash - Codeberg.org](https://codeberg.org/mro/geohash/commit/0a32c16b).

Using `link_flags` alone didn’t work. And had to add flags to `test/dune`, naturally.
