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

Fix discarded-qualifiers problems in ldlang.c

Fixes discarded-qualifiers warnings by ensuring const correctness in argument passing within ldlang.c.

This commit addresses discarded-qualifiers warnings in ldlang.c by ensuring const correctness. The archive_path function now returns a const char*, and input_statement_is_archive_path now takes a const char* sep argument. The memory pointed to by these arguments is writable, so there is no need to copy file_spec to insert a zero.

In Details

This commit fixes const violations in ldlang.c, specifically around the archive_path and input_statement_is_archive_path functions. The return type of archive_path and the sep argument of input_statement_is_archive_path are now const char*, aligning with the data's actual const-ness and resolving compiler warnings. The original code copied file_spec to insert a null terminator, but this is no longer necessary as the memory is writable.

For Context

The linker (ld) combines compiled object files into an executable program. ldlang.c handles the linker command language, which allows users to specify input files and linking options. This commit fixes compiler warnings related to const correctness by ensuring function arguments and return types are properly declared as const. This change makes the code safer by preventing accidental modification of read-only data.

Filed Under: linkerldconst correctness