[PATCH] gas: Use notes obstack for PowerPC symbol names

Alhuda Khan alhuda@research.digiscrypt.com
Sun Nov 22 04:07:43 GMT 2026


Hi,

While building gas with ASan I noticed ppc_frob_symbol() in gas/config/tc-ppc.c
leaks the symbol name it allocates. When it rewrites a symbol's name it does
snew = xstrndup(name, len) and passes that to S_SET_NAME(), but the xstrndup'd
buffer is never freed, so every such symbol leaks for the life of the assembler.

The patch switches that allocation to notes_memdup0(), so the name lives on the
notes obstack like the other gas symbol names and gets cleaned up with it
instead of leaking.

Tested on current master.

Thanks,
Alhuda Khan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ppc-symbol-name-leak.patch
Type: application/octet-stream
Size: 719 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20261122/3ab2ea35/attachment.obj>


More information about the Binutils mailing list