Ld: Fix discarded-qualifiers problems in ldelf.c
Calvin Owens confirms that their patches to fix discarded-qualifiers warnings in ldelf.c were also independently found and fixed by Mark Wielaard.
Calvin Owens responds to Mark Wielaard, noting that the discarded-qualifiers fixes in ldelf.c they submitted were independently discovered and resolved by Mark. Calvin indicates that his patches were created for local testing and offered to save time, but there’s no need for extra effort to use them.
- other
States that they independently found and fixed the same discarded-qualifiers issues in ldelf.c.
“This one I also found and fixed in almost the same way in https://inbox.sourceware.org/binutils/20260502170132.3303884-3-mark@klomp.org/ Likewise.”
- proposer
Acknowledges that the fixes were duplicated and says it's not necessary to use their patches.
“No problem at all. It's really simple stuff, I had spun them for some local testing and just thought they might save you all some time. Please don't go to any extra trouble to use them :)”
Technical Tradeoffs
- The patches address compiler warnings, leading to cleaner code.
- The fixes prevent potential unintended modification of constant data.
- The impact is relatively small, as the code likely functioned correctly even with the warnings.
In Details
This concerns fixes for -Wdiscarded-qualifiers warnings in the ldelf.c file of the binutils linker. These warnings occur when a const qualifier is implicitly removed during an assignment or initialization, potentially leading to unintended modification of constant data.
For Context
This discussion is about resolving compiler warnings in the binutils linker, specifically related to discarding const qualifiers. The const keyword in C/C++ indicates that a variable's value should not be changed. The linker combines compiled code into an executable program, and these warnings indicate potential issues where the linker might be inadvertently stripping away the const protection, which could lead to bugs.