public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] GCC Linker Warnings and GCC 12 Requirement
@ 2025-01-14 22:23 Oliver Smith-Denny via groups.io
  0 siblings, 0 replies; only message in thread
From: Oliver Smith-Denny via groups.io @ 2025-01-14 22:23 UTC (permalink / raw)
  To: devel@edk2.groups.io

Hi folks,

I currently have PR https://github.com/tianocore/edk2/pull/10585
up to enable linker warnings as errors for MSVC and GCC builds.
This helps catch critical errors produced at link time that edk2
builds were otherwise ignoring (e.g. things like not finding
a module entry point and so defaulting to an address, which would
cause executing at a random address in a binary).

However, GCC12+ ld warns about RWX segments in the ELF binary
that is being produced, which happens because of our custom
linker script. I toyed around with the linker script, but did
not get a configuration that produced different segments, it
was always one RWX segment. However, in the end this doesn't
actually matter, GenFw converts the ELF binary into a PE/COFF
binary and then we apply the memory protections in FW based
on our heuristics. So, I added --no-warn-rwx-segments, so that
the warning, now produced to an error, would not break the
build. This works for the edk2 containers, which are using
GCC12+.

However, I just noticed outside of the container that
--no-warn-rwx-segments was also added in GCC12+. In older
versions of GCC, ld will warn when an unrecognized linker
option is passed. I have enabled fatal-warnings, so that
warning gets promoted to an error and the build fails.
There does not appear to be any way to not warn when
unrecognized linker options are passed.

So, for older than GCC12, adding --no-warn-rwx-segments and
--fatal-warnings will break the build. It is easily fixable
by removing them. I have left the PR up as it does not break
edk2, as mentioned, and I believe that is the lesser of two
evils, as we are protected against potentially bad linker
warnings. I wanted to ensure folks were aware and had the
opportunity to comment on the PR and/or propose different
solutions.

Thanks,
Oliver


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120992): https://edk2.groups.io/g/devel/message/120992
Mute This Topic: https://groups.io/mt/110617354/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-01-14 22:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-14 22:23 [edk2-devel] GCC Linker Warnings and GCC 12 Requirement Oliver Smith-Denny via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox