forked from Imagelibrary/binutils-gdb
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user