[PATCH 4/4] ld: Fix discarded-qualifiers problems in ldelf.c

Calvin Owens calvin@wbinvd.org
Sun May 3 19:56:48 GMT 2026


On Sunday 05/03 at 14:34 +0200, Mark Wielaard wrote:
> Hi Calvin,
> 
> On Fri, Apr 24, 2026 at 07:19:47PM -0700, Calvin Owens wrote:
> >     ../../ld/ldelf.c: In function ‘ldelf_search_needed’:
> >     ../../ld/ldelf.c:538:34: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
> >       538 |                       if ((slash = strrchr (replacement, '/')) != NULL)
> >           |                                  ^
> > 
> > Fix this by passing the obviously equal non-const pointer to strrchr(),
> > instead of the const one.
> 
> This one I also found and fixed in almost the same way in
> https://inbox.sourceware.org/binutils/20260502170132.3303884-3-mark@klomp.org/
> 
> > 
> >     ../../ld/ldelf.c: In function ‘ldelf_parse_ld_so_conf_include’:
> >     ../../ld/ldelf.c:797:17: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
> >       797 |       char *p = strrchr (filename, '/');
> >           |                 ^~~~~~~
> > 
> > Fix this by declaring the local pointer varaible as const, since it is
> > not modified.
> 
> Likewise.
> 
> Again my apologies for not seeing your patch earlier. It would have
> saved me some unnecessary work.

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 :)

Thanks,
Calvin

> Cheers,
> 
> Mark


More information about the Binutils mailing list