Do not pass --build-id to linker from gcc
arm, c, gcc
Solution
I think these options will do what you want:
-Wl,--build-id=none
Passing none for style disables the setting from any --build-id options earlier on the command line.
— ld manual
Problem
I'm trying to compile for an embedded arm processor using `gcc-arm-linux-gnueabi`, and `-nostdlib` to remove the dependencies on the c libraries and startup files. The chip doesn't have any way of interpreting elf files, so using `objcopy -O binary`, I can remove the elf headers from it. However, if I leave the build ID in, then the binary has the build ID at the start of the output, and so it fails to run. I can remove the build id in the linker script using `/DISCARD/ : { *(.note.gnu.build-id) *(.ARM.attributes) }`, however then the linker warns about `.note.gnu.build-id section discarded, --build-id ignored.`. While this works fine, and the code runs on the chip fine, I'd like to not have to pass and then drop the build ID. Is there any way to instruct `gcc` to pass commands to the linker without also passing `--build-id`?