GCOV in standalone env, nostdlib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I am trying to understand the limitations (if any libgcc) has concerning
embedded targets.

In particular I am attempting to follow the instructions here: Freestanding
Environments (Using the GNU Compiler Collection (GCC))
<https://gcc.gnu.org/onlinedocs/gcc/Freestanding-Environments.html> to
obtain code coverage; I can compile, however I am seeing some linker errors
like the following:

```bash
/usr/bin/ld:
/tmp/ccX2ca3G.ltrans0.ltrans.o:/edk2/OvmfPkg/EmuVariableFvbRuntimeDxe/FvbCov.c:83:
undefined reference to `my_info'
/usr/bin/ld:
/usr/lib/gcc/x86_64-linux-gnu/12/libgcov.a(_gcov_info_to_gcda.o): in
function `__gcov_info_to_gcda':
(.text+0x31d): undefined reference to `mmap'
/usr/bin/ld:
/usr/lib/gcc/x86_64-linux-gnu/12/libgcov.a(_gcov_info_to_gcda.o): in
function `__gcov_info_to_gcda.cold':
(.text.unlikely+0x1): undefined reference to `abort'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
```

My environment lacks any standard lib and I have the following
compiler/linker options:

compiler
```bash
INFO - "gcc" -MMD -MF
/edk2/Build/Ovmf3264/DEBUG_GCC5/X64/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb/OUTPUT/FvbCov.obj.deps
-g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror
-Wno-array-bounds -include AutoGen.h -fno-common -ffunction-sections
-fdata-sections -DSTRING_ARRAY_NAME=EmuVariableFvbRuntimeDxeStrings -m64
-fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
-fno-asynchronous-unwind-tables -Wno-address -flto -DUSING_LTO -Os
-coverage -mno-mmx -mno-sse -D DISABLE_NEW_DEPRECATED_INTERFACES -D
ENABLE_MD5_DEPRECATED_INTERFACES -c -o
/edk2/Build/Ovmf3264/DEBUG_GCC5/X64/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb/OUTPUT/./FvbCov.obj
-I/edk2/OvmfPkg/EmuVariableFvbRuntimeDxe
-I/edk2/Build/Ovmf3264/DEBUG_GCC5/X64/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb/DEBUG
-I/edk2/MdePkg -I/edk2/MdePkg/Include -I/edk2/MdePkg/Test/UnitTest/Include
-I/edk2/MdePkg/Include/X64 -I/edk2/MdeModulePkg
-I/edk2/MdeModulePkg/Include -I/edk2/OvmfPkg -I/edk2/OvmfPkg/Include
-I/edk2/OvmfPkg/Csm/Include /edk2/OvmfPkg/EmuVariableFvbRuntimeDxe/FvbCov.c
```

linker
```bash
"gcc" -o
/edk2/Build/Ovmf3264/DEBUG_GCC5/X64/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb/DEBUG/EmuVariableFvbRuntimeDxe.dll
-nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x40
-Wl,--entry,_ModuleEntryPoint -u _ModuleEntryPoint
-Wl,-Map,/edk2/Build/Ovmf3264/DEBUG_GCC5/X64/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb/DEBUG/EmuVariableFvbRuntimeDxe.map,--whole-archive
-Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie -flto -Os -fprofile-arcs
-ftest-coverage -fprofile-info-section -z common-page-size=0x1000
-Wl,--start-group,@/edk2/Build/Ovmf3264/DEBUG_GCC5/X64/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb/OUTPUT/static_library_files.lst,--end-group
-g -Os -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror
-Wno-array-bounds -include AutoGen.h -fno-common -ffunction-sections
-fdata-sections -DSTRING_ARRAY_NAME=EmuVariableFvbRuntimeDxeStrings -m64
-fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))"
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie
-fno-asynchronous-unwind-tables -Wno-address -flto -DUSING_LTO -Os
-coverage -mno-mmx -mno-sse -D DISABLE_NEW_DEPRECATED_INTERFACES -D
ENABLE_MD5_DEPRECATED_INTERFACES -Wl,--defsym=PECOFF_HEADER_SIZE=0x228
-Wl,--script=/edk2/BaseTools/Scripts/GccBase.lds -Wno-error
```

Let me know if there are additional info, in the meantime I will create a
more minimal build environment to try and narrow down the possibilities.

Thank you :)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux