public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Erich <erichmcmill@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: GCOV in standalone env, nostdlib
Date: Fri, 28 Oct 2022 11:38:56 -0500	[thread overview]
Message-ID: <CABc5znSRfE-omkObRpo7Zc+hjUmuDO1fxh48apL=RX_9+=0p2A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3616 bytes --]

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 :)

                 reply	other threads:[~2022-10-28 16:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABc5znSRfE-omkObRpo7Zc+hjUmuDO1fxh48apL=RX_9+=0p2A@mail.gmail.com' \
    --to=erichmcmill@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).