https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97060
Bug ID: 97060
Summary: Missing DW_AT_declaration=1 in dwarf data
Product: gcc
Version: 10.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: jolsa at redhat dot com
Target Milestone: ---
We are missing expected declaration tag - DW_AT_declaration : 1 for function
in debug info data.
The problem we see is:
- fs/init.c calls vfs_getattr function
- vfs_getattr is defined outside the fs/init.c
- once compiled, debug info data for vfs_getattr should contain declaration
tag - DW_AT_declaration : 1, but it's missing
gcc version: gcc (GCC) 10.2.1 20200826 (Red Hat 10.2.1-3)
Unfortunately the issue can be so far reproduced only inside container,
I tried to narrow it down to single fs/init.o object.
Following steps create fs/init.o binary in kernel tree within the container:
# podman image pull
registry.gitlab.com/cki-project/containers/builder-rawhide:latest
# podman image list
# podman run -it /bin/bash
# git clone https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
--depth 1
# curl
https://xci32.lab.eng.rdu2.redhat.com/cki-project/cki-pipeline/-/jobs/974002/artifacts/raw/artifacts/kernel-bpf-next-x86_64-cd04b04de119a222c83936f7e9dbd46a650cb688.config
-o bpf-next/.config
# cd bpf-next/
# make oldconfig # might need some ENTERs
# make fs/ -j
# gcc -Wp,-MMD,fs/.init.o.d -nostdinc -isystem
/usr/lib/gcc/x86_64-redhat-linux/10/include -I./arch/x86/include
-I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi
-I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi
-include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h
-D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE
-Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security
-std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1
-falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3
-mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare
-fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern
-mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks
-Wno-frame-address -Wno-format-truncation -Wno-format-overflow
-Wno-address-of-packed-member -O2 -fno-allow-store-data-races
-Wframe-larger-than=2048 -fstack-protector -Wno-unused-but-set-variable
-Wimplicit-fallthrough -Wno-unused-const-variable -fno-var-tracking-assignments
-g -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -flive-patching=inline-clone
-Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation
-Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict
-Wno-maybe-uninitialized -fno-strict-overflow -fno-merge-all-constants
-fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time
-Werror=incompatible-pointer-types -Werror=designated-init
-fmacro-prefix-map=./= -fcf-protection=none -Wno-packed-not-aligned
-DKBUILD_MODFILE='"fs/init"' -DKBUILD_BASENAME='"init"'
-DKBUILD_MODNAME='"init"' -c -o fs/init.o fs/init.c
# readelf --debug fs/init.o
...
<1><9145>: Abbrev Number: 46 (DW_TAG_subprogram)
<9146> DW_AT_external: 1
<9146> DW_AT_name: (indirect string, offset: 0x531c): vfs_getattr
<914a> DW_AT_decl_file : 7
<914b> DW_AT_decl_line : 3148
<914d> DW_AT_decl_column : 12
<914e> DW_AT_prototyped : 1
<914e> DW_AT_type: <0xa9>
<9152> DW_AT_sibling : <0x916b>
<2><9156>: Abbrev Number: 3 (DW_TAG_formal_parameter)
<9157> DW_AT_type: <0x3573>
<2><915b>: Abbrev Number: 3 (DW_TAG_formal_parameter)
<915c> DW_AT_type: <0x893a>
<2><9160>: Abbrev Number: 3 (DW_TAG_formal_parameter)
<9161> DW_AT_type: <0x111>
<2><9165>: Abbrev Number: 3 (DW_TAG_formal_parameter)
<9166> DW_AT_type: <0x4c>
When we link the final kernel binary the debug info data contains multiple
records for vfs_getattr,
and neither has 'declaration' tag and it confuses pahole tool that uses this
data to get function
records and skips declarations.
The problem is for more functions, vfs_getattr is just one example.