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

ld: Fix calls to strchr that discard or use wrong const qualifiers

Fixes const qualifier issues when calling strchr in the linker, preventing compiler warnings.

This commit addresses issues where calls to strchr in the linker code were discarding or using incorrect const qualifiers, leading to compiler warnings. The code is updated to ensure const correctness, which resolves these warnings and improves code quality.

In Details

This commit targets const correctness in the linker's source code, specifically around the usage of the strchr function across multiple architectures (BEOS, PE, PEP, SPUELF) and core linker functionality (ldelf.c). The changes involve adjusting variable types to const char * or introducing non-const copies where necessary to avoid discarding qualifiers.

For Context

When compiling C code, it is essential to maintain const-correctness to prevent accidental modification of constant data. The strchr function, which searches for a character within a string, returns a pointer to the character. This commit fixes type mismatches where a const char * return from strchr was assigned to a char *, or vice versa. These fixes prevent compiler warnings and improve code safety.

Filed Under: ldconststrchrwarning