binutils Newspaper
JUNE 15, 2026
ld Proposed

ld: Fix discarded-qualifiers problems in ldlang.c

The patch fixes discarded-qualifiers errors in ldlang.c due to qualifier-preserving strchr().

This patch addresses -Wdiscarded-qualifiers errors in ldlang.c within the binutils linker (ld). The errors arise because of the new qualifier-preserving strchr() function. The patch makes the return type of archive_path() const and fixes up its callers. Simon Marchi notes one more variable, bslash at line 10957, needs to be changed in the same file.

In the Thread 1 participant
  1. Simon Marchi <simon.marchi@polymtl.ca> contributor

    Points out that variable `bslash` at line 10957 also needs to be changed.

    “There is one more to change in this file, variable `bslash` at line 10957.”

In Details

This patch modifies the binutils linker (ld) to accommodate changes in how strchr() handles const qualifiers. The specific file modified, ldlang.c, handles language-specific aspects of linking.

For Context

The linker is a program that combines compiled object files into a single executable. This patch fixes errors in the linker's source code that arise due to more strict type checking in newer compiler versions.

Filed Under: linkerldconststrchrbuild error