Test case: #include <stdio.h> int main() { printf("Hello world!\n"); return 0; } ==74578==ERROR: LeakSanitizer: detected memory leaks Direct leak of 5664 byte(s) in 1 object(s) allocated from: #0 0x7fedf6816860 in __interceptor_malloc ../../.././libsanitier/asasn/asan_malloc_linux.cc:62 #1 0x560879e0b151 in parse_args (/usr/bin/riscv32-unknown-elf-ld+03d151) binutils version 2.34 Checked on the source code, I did not see any free action on below shortopts, longopts, really_longopts variable. ld/lexsup.c shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2); longopts = (struct option *) xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1)); really_longopts = (struct option *) malloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8da4f428d1663541bdd49f5aa2041d06ac6a06de commit 8da4f428d1663541bdd49f5aa2041d06ac6a06de Author: Alan Modra <amodra@gmail.com> Date: Mon Dec 14 19:34:20 2020 +1030 PR26836, memory leak in parse_args PR 26836 * lexsup.c (parse_args): Free really_longopts, longopts and shortopts.
Fixed for 2.36