aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-dedup.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2024-07-15 19:42:10 +0100
committerNick Alcock <nick.alcock@oracle.com>2024-07-31 21:02:05 +0100
commit87b2f673102884d7c69144c85a26ed5dbaa4f86a (patch)
tree4e1728d7a0facf14c40cb9422b5586ec9ce7abe0 /libctf/ctf-dedup.c
parent2b35088f30d95cd45bb572765a7b01260a1d8ee2 (diff)
downloadgdb-87b2f673102884d7c69144c85a26ed5dbaa4f86a.zip
gdb-87b2f673102884d7c69144c85a26ed5dbaa4f86a.tar.gz
gdb-87b2f673102884d7c69144c85a26ed5dbaa4f86a.tar.bz2
libctf: fix linking of non-root-visible types
If you deduplicate non-root-visible types, the resulting type should still be non-root-visible! We were promoting all such types to root-visible, and re-demoting them only if their names collided (which might happen on cu-mapped links if multiple compilation units with conflicting types are fused into one child dict). This "worked" before now, in that linking at least didn't fail (if you don't mind having your non-root flag value destroyed if you're adding non-root-visible types), but now that conflicting enumerators cause their containing enums to become conflicted (enums which might have *different names*), this caused the linker to crash when it hit two enumerators with conflicting values. Not testable in ld because cu-mapped links are not exposed to ld, but can be tested via direct creation of libraries and calls to ctf_link directly. (This also tests the ctf_dump non-root type printout, which before now was untested.) libctf/ * ctf-dedup.c (ctf_dedup_emit_type): Non-root-visible input types should be emitted as non-root-visible output types. * testsuite/libctf-writable/ctf-nonroot-linking.c: New test. * testsuite/libctf-writable/ctf-nonroot-linking.lk: New test.
Diffstat (limited to 'libctf/ctf-dedup.c')
-rw-r--r--libctf/ctf-dedup.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libctf/ctf-dedup.c b/libctf/ctf-dedup.c
index 6c58daa..8bfd839 100644
--- a/libctf/ctf-dedup.c
+++ b/libctf/ctf-dedup.c
@@ -2640,7 +2640,7 @@ ctf_dedup_emit_type (const char *hval, ctf_dict_t *output, ctf_dict_t **inputs,
int input_num = CTF_DEDUP_GID_TO_INPUT (id);
int output_num = (uint32_t) -1; /* 'shared' */
int cu_mapped = *(int *)arg;
- int isroot = 1;
+ int isroot;
int is_conflicting;
ctf_next_t *i = NULL;
@@ -2708,9 +2708,11 @@ ctf_dedup_emit_type (const char *hval, ctf_dict_t *output, ctf_dict_t **inputs,
}
name = ctf_strraw (real_input, tp->ctt_name);
+ isroot = LCTF_INFO_ISROOT (real_input, tp->ctt_info);
/* Hide conflicting types, if we were asked to: also hide if a type with this
- name already exists and is not a forward. */
+ name already exists and is not a forward, or if this type is hidden on the
+ input. */
if (cu_mapped && is_conflicting)
isroot = 0;
else if (name