Skip to content

build: build static module archives with PIC#39

Open
ssam18 wants to merge 1 commit into
snort3:masterfrom
ssam18:build/pic-only-static-modules
Open

build: build static module archives with PIC#39
ssam18 wants to merge 1 commit into
snort3:masterfrom
ssam18:build/pic-only-static-modules

Conversation

@ssam18
Copy link
Copy Markdown

@ssam18 ssam18 commented Apr 27, 2026

On Ubuntu 22.04+ and other distros where the toolchain defaults to PIE executables, linking the libdaq_static_*.a archives into a PIE binary fails with relocation R_X86_64_32S ... can not be used when making a PIE object. This bites anyone building Snort 3 with --enable-static-daq (the default) against a vanilla ./configure && make install of libdaq, and the CFLAGS=-fPIC workaround is easy to miss. Adding [pic-only] to LT_INIT tells libtool to emit PIC objects for the static archives by default, same approach libpcap and friends took for the same reason. See snort3/snort3#320.

Pass [pic-only] to LT_INIT so libtool emits PIC objects for the
`-static` module archives (libdaq_static_afpacket.a and friends).

Without this, on Linux toolchains that default to PIE (Ubuntu 22.04+,
recent Debian and Fedora), linking those archives into a PIE executable
fails with:

  relocation R_X86_64_32S against `.bss' can not be used when making
  a PIE object; recompile with -fPIE

Snort 3 with --enable-static-daq is the most common path that hits this.
The workaround until now has been to pass CFLAGS=-fPIC at configure
time, which is easy to miss. Making PIC the default removes the foot-gun
at negligible runtime cost on x86_64.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant