mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-25 16:57:52 +00:00
include, libctf: add cth_parent_strlen CTFv4 header field
The first format difference between v3 and v4 is a cth_parent_strlen header field. This field (obviously not present in BTF) is populated from the string table length of the parent at serialization time (protection against being serialized before the parent is will be added in a later commit in this series), and will be used at open time to prohibit opening of dicts with a different strlen (which would corrupt the child's string table if it was shared with the parent). For now, just add the field, populate it at serialization time when linking (when not linking, no deduplication is done and the correct value remains unchanged), and dump it. include/ * ctf.h (ctf_header) [cth_parent_strlen]: New. libctf/ * ctf-dump.c (ctf_dump_header_sizefield): New. (ctf_dump_header): Use to dump the cth_parent_strlen. * ctf-open.c (upgrade_header_v2): Populate cth_parent_strlen. (upgrade_header_v3): Likewise. (ctf_flip_header): Flip it. (ctf_bufopen): Drop unnecessary initialization. * ctf-serialize.c (ctf_serialize): Write it out when linking. ld/ * testsuite/ld-ctf/data-func-conflicted-vars.d: Skip the nwe dump output. * testsuite/ld-ctf/data-func-conflicted.d: Likewise.
This commit is contained in:
@@ -1104,7 +1104,14 @@ ctf_serialize (ctf_dict_t *fp, size_t *bufsiz)
|
||||
assert (t == (unsigned char *) buf + sizeof (ctf_header_t) + hdr.cth_stroff);
|
||||
|
||||
/* Construct the final string table and fill out all the string refs with the
|
||||
final offsets. */
|
||||
final offsets. At link time, before the strtab can be constructed, child
|
||||
dicts also need their cth_parent_strlen header field updated to match the
|
||||
parent's. (These are always newly-created dicts, so we don't need to worry
|
||||
about the upgraded-from-v3 case, which must always retain a
|
||||
cth_parent_strlen value of 0.) */
|
||||
|
||||
if ((fp->ctf_flags & LCTF_LINKING) && fp->ctf_parent)
|
||||
fp->ctf_header->cth_parent_strlen = fp->ctf_parent->ctf_str[CTF_STRTAB_0].cts_len;
|
||||
|
||||
strtab = ctf_str_write_strtab (fp);
|
||||
|
||||
@@ -1126,6 +1133,7 @@ ctf_serialize (ctf_dict_t *fp, size_t *bufsiz)
|
||||
hdrp->cth_strlen = strtab->cts_len;
|
||||
buf_size += hdrp->cth_strlen;
|
||||
*bufsiz = buf_size;
|
||||
hdrp->cth_parent_strlen = fp->ctf_header->cth_parent_strlen;
|
||||
|
||||
return buf;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user