diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2024-07-15 21:01:40 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2025-02-28 14:47:24 +0000 |
commit | 6c776899632eab5d513d81364efc7a167a2838b2 (patch) | |
tree | 482112a139dacbe0df04e14b5950dcdcca1b3050 /libctf/ctf-dump.c | |
parent | 70d05ab0b2c6ba8d16521a22f557ca86421f1281 (diff) | |
download | binutils-6c776899632eab5d513d81364efc7a167a2838b2.zip binutils-6c776899632eab5d513d81364efc7a167a2838b2.tar.gz binutils-6c776899632eab5d513d81364efc7a167a2838b2.tar.bz2 |
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.
Diffstat (limited to 'libctf/ctf-dump.c')
-rw-r--r-- | libctf/ctf-dump.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c index be615de..514fa3d6 100644 --- a/libctf/ctf-dump.c +++ b/libctf/ctf-dump.c @@ -265,6 +265,24 @@ ctf_dump_header_strfield (ctf_dict_t *fp, ctf_dump_state_t *state, return (ctf_set_errno (fp, errno)); } +/* Dump one size field from the file header into the cds_items. */ +static int +ctf_dump_header_sizefield (ctf_dict_t *fp, ctf_dump_state_t *state, + const char *name, uint32_t value) +{ + char *str; + if (value) + { + if (asprintf (&str, "%s: %x\n", name, value) < 0) + goto err; + ctf_dump_append (state, str); + } + return 0; + + err: + return (ctf_set_errno (fp, errno)); +} + /* Dump one section-offset field from the file header into the cds_items. */ static int ctf_dump_header_sectfield (ctf_dict_t *fp, ctf_dump_state_t *state, @@ -366,6 +384,9 @@ ctf_dump_header (ctf_dict_t *fp, ctf_dump_state_t *state) hp->cth_cuname) < 0) goto err; + if (ctf_dump_header_sizefield (fp, state, "Parent strlen", hp->cth_parent_strlen) < 0) + goto err; + if (ctf_dump_header_sectfield (fp, state, "Label section", hp->cth_lbloff, hp->cth_objtoff) < 0) goto err; |