binutils-gdb/ld/testsuite/ld-ctf
Nick Alcock f8da1a05db
libctf: dedup: enums with overlapping enumerators are conflicting
The CTF deduplicator was not considering enumerators inside enum types to be
things that caused type conflicts, so if the following two TUs were linked
together, you would end up with the following in the resulting dict:

1.c:
enum foo { A, B };

2.c:
enum bar { A, B };

linked:

enum foo { A, B };
enum bar { A, B };

This does work -- but it's not something that's valid C, and the general
point of the shared dict is that it is something that you could potentially
get from any valid C TU.

So consider such types to be conflicting, but obviously don't consider
actually identical enums to be conflicting, even though they too have (all)
their identifiers in common.  This involves surprisingly little code. The
deduplicator detects conflicting types by counting types in a hash table of
hash tables:

decorated identifier -> (type hash -> count)

where the COUNT is the number of times a given hash has been observed: any
name with more than one hash associated with it is considered conflicting
(the count is used to identify the most common such name for promotion to
the shared dict).

Before now, those identifiers were all the identifiers of types (possibly
decorated with their namespace on the front for enumerator identifiers), but
we can equally well put *enumeration constant names* in there, undecorated
like the identifiers of types in the global namespace, with the type hash
being the hash of each enum containing that enumerator.  The existing
conflicting-type-detection code will then accurately identify distinct enums
with enumeration constants in common.  The enum that contains the most
commonly-appearing enumerators will be promoted to the shared dict.

libctf/
	* ctf-impl.h (ctf_dedup_t) <cd_name_counts>: Extend comment.
	* ctf-dedup.c (ctf_dedup_count_name): New, split out of...
	(ctf_dedup_populate_mappings): ... here.  Call it for all
	* enumeration constants in an enum as well as types.

ld/
	* testsuite/ld-ctf/enum-3.c: New test CTF.
	* testsuite/ld-ctf/enum-4.c: Likewise.
	* testsuite/ld-ctf/overlapping-enums.d: New test.
	* testsuite/ld-ctf/overlapping-enums-2.d: Likewise.
2024-06-18 13:20:31 +01:00
..
A-2.c
A.c
array-char-conflicting-1.c libctf: impose an ordering on conflicting types 2022-04-28 11:47:12 +01:00
array-char-conflicting-2.c libctf: impose an ordering on conflicting types 2022-04-28 11:47:12 +01:00
array-char.c
array-conflicted-ordering.d libctf: impose an ordering on conflicting types 2022-04-28 11:47:12 +01:00
array-extern.c libctf: impose an ordering on conflicting types 2022-04-28 11:47:12 +01:00
array-extern.d libctf: impose an ordering on conflicting types 2022-04-28 11:47:12 +01:00
array-int.c
array.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
B-2.c
B.c
C-2.c
C.c
child-float.c
child-int.c
conflicting-cycle-1.B-1.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-cycle-1.B-2.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-cycle-1.parent.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-cycle-2.A-1.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-cycle-2.A-2.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-cycle-2.parent.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-cycle-3.C-1.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-cycle-3.C-2.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-cycle-3.parent.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-enums.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
conflicting-typedefs.d libctf: impose an ordering on conflicting types 2022-04-28 11:47:12 +01:00
cross-tu-1.c
cross-tu-2.c
cross-tu-conflicting-2.c
cross-tu-cyclic-1.c
cross-tu-cyclic-2.c
cross-tu-cyclic-3.c
cross-tu-cyclic-4.c
cross-tu-cyclic-conflicting.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
cross-tu-cyclic-nonconflicting.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
cross-tu-into-cycle.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
cross-tu-noncyclic.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
ctf.exp Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
cycle-1.c
cycle-1.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
cycle-2.A.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
cycle-2.B.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
cycle-2.C.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
data-func-1.c ld, ctf: new and adjusted CTF tests due to func info / object data sections 2020-11-20 13:34:10 +00:00
data-func-2.c libctf, ld: fix data symbol test with newer GCC 2021-01-19 12:45:18 +00:00
data-func-conflicted-vars.d ld: Compile 2 CTF tests with -O2 2022-07-25 09:59:47 -07:00
data-func-conflicted.d ld: Compile 2 CTF tests with -O2 2022-07-25 09:59:47 -07:00
diag-ctf-version-0.d
diag-ctf-version-0.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-ctf-version-2-unsupported-feature.d
diag-ctf-version-2-unsupported-feature.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-ctf-version-f.d binutils, ld: dequote libctf error messages 2020-08-27 13:16:39 +01:00
diag-ctf-version-f.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-cttname-invalid.d binutils, ld: dequote libctf error messages 2020-08-27 13:16:39 +01:00
diag-cttname-invalid.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-cttname-null.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
diag-cttname-null.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-cuname.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
diag-cuname.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-decompression-failure.d binutils, ld: dequote libctf error messages 2020-08-27 13:16:39 +01:00
diag-decompression-failure.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-parlabel.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
diag-parlabel.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-parname.d binutils, ld: dequote libctf error messages 2020-08-27 13:16:39 +01:00
diag-parname.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-strlen-invalid.d libctf, ld: diagnose corrupted CTF header cth_strlen 2022-03-23 13:48:32 +00:00
diag-strlen-invalid.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-unsupported-flag.d binutils, ld: dequote libctf error messages 2020-08-27 13:16:39 +01:00
diag-unsupported-flag.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
diag-wrong-magic-number-mixed.d libctf, ld: dump enums: generally improve dump formatting 2021-01-05 14:53:39 +00:00
diag-wrong-magic-number.d binutils, ld: dequote libctf error messages 2020-08-27 13:16:39 +01:00
diag-wrong-magic-number.s Modify ld-ctf test files to suit ARM 2022-09-14 10:19:57 +09:30
enum-2.c
enum-3.c libctf: dedup: enums with overlapping enumerators are conflicting 2024-06-18 13:20:31 +01:00
enum-4.c libctf: dedup: enums with overlapping enumerators are conflicting 2024-06-18 13:20:31 +01:00
enum-forward.c libctf, ld: fix formatting of forwards to unions and enums 2021-01-05 14:53:40 +00:00
enum-forward.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
enum.c
enums.c libctf, ld: dump enums: generally improve dump formatting 2021-01-05 14:53:39 +00:00
enums.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
forward.c libctf, ld: prohibit getting the size or alignment of forwards 2021-01-05 14:53:39 +00:00
forward.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
function.c
function.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
nonrepresentable-1.c libctf, ld: fix test results for upstream GCC 2021-05-06 09:31:31 +01:00
nonrepresentable-2.c libctf, ld: fix test results for upstream GCC 2021-05-06 09:31:31 +01:00
nonrepresentable-member.c libctf, ld: handle nonrepresentable types better 2021-10-25 11:17:05 +01:00
nonrepresentable-member.d libctf, ld: handle nonrepresentable types better 2021-10-25 11:17:05 +01:00
nonrepresentable.d kvx: New port. 2023-08-16 14:22:54 +01:00
overlapping-enums-2.d libctf: dedup: enums with overlapping enumerators are conflicting 2024-06-18 13:20:31 +01:00
overlapping-enums.d libctf: dedup: enums with overlapping enumerators are conflicting 2024-06-18 13:20:31 +01:00
slice.c libctf: support encodings for enums 2021-03-18 12:40:41 +00:00
slice.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
super-sub-cycles.c
super-sub-cycles.d binutils, ld: make objdump --ctf's parameter optional 2021-10-25 11:17:03 +01:00
typedef-int.c
typedef-long.c
union-1.c