Files
binutils-gdb/ld/testsuite/ld-ctf/data-func-conflicted.d
Nick Alcock 0e28ade476 libctf, ld: properly deduplicate function types
Some type kinds in CTF (functions, arrays, pointers, slices, and
cvr-quals) are intrinsically nameless: the ctt_name field in the CTF
is always zero, and the libctf API provides no way to set a name.
But the compiler can and does sometimes set names for some of these
kinds: in particular, the name it sets on CTF_K_FUNCTION types is the
means it uses to force the name of the function into the string table
so that it can point at it from the function info section.

So null out the name at hashing time so that the deduplicator can
correctly detect that e.g. function types identical but for name should
be considered truly identical, since they will not have a name when the
deduplicator re-emits them into the output.

ld/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/ld-ctf/data-func-conflicted.d: Shrink the expected
	size of the type section now that function types are being
	deduplicated properly.

libctf/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-dedup.c (ctf_dedup_rhash_type): Null out the names of nameless
	type kinds, just in case the input has named them.
2020-11-20 13:34:10 +00:00

64 lines
1.2 KiB
Makefile

#as:
#source: data-func-1.c
#source: data-func-2.c
#objdump: --ctf=.ctf
#ld: -shared -s
#name: Conflicted data syms, partially indexed, stripped
.*: +file format .*
Contents of CTF section \.ctf:
Header:
Magic number: dff2
Version: 4 \(CTF_VERSION_3\)
#...
Data object section: .* \(0xc bytes\)
Function info section: .* \(0x40 bytes\)
Object index section: .* \(0xc bytes\)
Type section: .* \(0xe8 bytes\)
String section: .*
#...
Data objects:
bar -> struct var_3
var_1 -> foo_t
var_666 -> foo_t \*
Function objects:
func_[0-9]* -> void \*\(\*\) \(const char \*restrict, int \(\*\)\(\*\) \(const char \*\)\)
#...
Types:
#...
.*: struct var_3 .*
#...
CTF archive member: .*/data-func-1\.c:
Header:
Magic number: dff2
Version: 4 \(CTF_VERSION_3\)
#...
Parent name: \.ctf
Compilation unit name: .*/data-func-1\.c
Data object section: .* \(0xfa4 bytes\)
Type section: .* \(0xc bytes\)
String section: .*
Labels:
Data objects:
var_[0-9]* -> foo_t
var_[0-9]* -> foo_t
var_[0-9]* -> foo_t
var_[0-9]* -> foo_t
var_[0-9]* -> foo_t
var_[0-9]* -> foo_t
var_[0-9]* -> foo_t
#...
Function objects:
Variables:
Types:
80000001: foo_t .* -> .* int .*
#...