Undefined symbol "_mcount" when cross-compiling for aarch64

87 Views Asked by At

I'm trying to use gprof for a project that runs in a small embedded OS (https://github.com/smartobjectoriented/so3). Compilation for this OS is done using the "aarch64-none-linux-gnu-" toolchain (version 11.3.Rel1) and uses a musl libc and cmake. I've added the "-pg" option to both build and linking of my application using

target_compile_options(letter_count.elf PRIVATE -pg)

target_link_options(letter_count.elf PRIVATE -pg)

However when I try to build, I get this error

aarch64-none-linux-gnu-ld: CMakeFiles/letter_count.elf.dir/letter_count.c.obj: in function `count_letters': /home/anthony/Repositories/so3/usr/src/letter_count.c:25: undefined reference to `_mcount'

It happens at linking time so the build seems to understand the "-pg" option (and adds the "_mcount" symbol) but not the linker. Is the _mcount symbols not available in this toolchain ? Or is there another mistake I may have made ?

0

There are 0 best solutions below