binutils Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ld

Fix discarded-qualifiers problems in ldlang.c

Fixes -Wdiscarded-qualifiers errors by using const char* where appropriate in ldlang.c.

Addresses -Wdiscarded-qualifiers warnings in ldlang.c by ensuring that the return value of strchr is assigned to a const char* where appropriate. The archive_path function now returns a const char*, and input_statement_is_archive_path now has a const char* sep argument.

In Details

This commit fixes const correctness issues in ldlang.c, specifically around the use of strchr. The return value of strchr is now assigned to a const char* to avoid -Wdiscarded-qualifiers warnings. The changes involves archive_path and input_statement_is_archive_path.

For Context

When compiling C code, the compiler can issue warnings if a pointer to a constant string is assigned to a pointer to a non-constant string, which can lead to unexpected behavior. The -Wdiscarded-qualifiers compiler warning flags these situations. This commit fixes these warnings in the linker's source code by ensuring that string pointers are correctly declared as const when they point to constant data.

Filed Under: ldconstwarningC23