public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Oliver Smith-Denny via groups.io" <osde=linux.microsoft.com@groups.io>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: [edk2-devel] GCC Linker Warnings and GCC 12 Requirement
Date: Tue, 14 Jan 2025 14:23:02 -0800	[thread overview]
Message-ID: <236138ad-b25d-4522-9d84-a3634980dbc5@linux.microsoft.com> (raw)

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]
-=-=-=-=-=-=-=-=-=-=-=-



                 reply	other threads:[~2025-01-14 22:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=236138ad-b25d-4522-9d84-a3634980dbc5@linux.microsoft.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox