• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisãofe4c2d55634c700ba527ac4183e05c66e9f93c62 (tree)
Hora2020-06-26 23:56:39
AutorNick Alcock <nick.alcock@orac...>
CommiterNick Alcock

Mensagem de Log

libctf: create: non-root-visible types should not appear in name tables

We were accidentally interning newly-added and newly-opened
non-root-visible types into name tables, and removing names from name
tables when such types were removed. This is very wrong: the whole
point of non-root-visible types is they do not go in name tables and
cannot be looked up by name. This bug made non-root-visible types
basically identical to root-visible types, right back to the earliest
days of libctf in the Solaris era.

libctf/
* ctf-open.c (init_types): Only intern root-visible types.
* ctf-create.c (ctf_dtd_insert): Likewise.
(ctf_dtd_delete): Only remove root-visible types.
(ctf_rollback): Likewise.
(ctf_add_generic): Adjust.
(ctf_add_struct_sized): Adjust comment.
(ctf_add_union_sized): Likewise.
(ctf_add_enum): Likewise.
* ctf-impl.h (ctf_dtd_insert): Adjust prototype.

Mudança Sumário

Diff

--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,3 +1,15 @@
1+2020-06-26 Nick Alcock <nick.alcock@oracle.com>
2+
3+ * ctf-open.c (init_types): Only intern root-visible types.
4+ * ctf-create.c (ctf_dtd_insert): Likewise.
5+ (ctf_dtd_delete): Only remove root-visible types.
6+ (ctf_rollback): Likewise.
7+ (ctf_add_generic): Adjust.
8+ (ctf_add_struct_sized): Adjust comment.
9+ (ctf_add_union_sized): Likewise.
10+ (ctf_add_enum): Likewise.
11+ * ctf-impl.h (ctf_dtd_insert): Adjust prototype.
12+
113 2020-03-11 John Baldwin <jhb@FreeBSD.org>
214
315 * swap.h (bswap_identity_64): Make static.
--- a/libctf/ctf-create.c
+++ b/libctf/ctf-create.c
@@ -597,13 +597,13 @@ ctf_name_table (ctf_file_t *fp, int kind)
597597 }
598598
599599 int
600-ctf_dtd_insert (ctf_file_t *fp, ctf_dtdef_t *dtd, int kind)
600+ctf_dtd_insert (ctf_file_t *fp, ctf_dtdef_t *dtd, int flag, int kind)
601601 {
602602 const char *name;
603603 if (ctf_dynhash_insert (fp->ctf_dthash, (void *) dtd->dtd_type, dtd) < 0)
604604 return -1;
605605
606- if (dtd->dtd_data.ctt_name
606+ if (flag == CTF_ADD_ROOT && dtd->dtd_data.ctt_name
607607 && (name = ctf_strraw (fp, dtd->dtd_data.ctt_name)) != NULL)
608608 {
609609 if (ctf_dynhash_insert (ctf_name_table (fp, kind)->ctn_writable,
@@ -646,7 +646,8 @@ ctf_dtd_delete (ctf_file_t *fp, ctf_dtdef_t *dtd)
646646 }
647647
648648 if (dtd->dtd_data.ctt_name
649- && (name = ctf_strraw (fp, dtd->dtd_data.ctt_name)) != NULL)
649+ && (name = ctf_strraw (fp, dtd->dtd_data.ctt_name)) != NULL
650+ && LCTF_INFO_ISROOT (fp, dtd->dtd_data.ctt_info))
650651 {
651652 ctf_dynhash_remove (ctf_name_table (fp, kind)->ctn_writable,
652653 name);
@@ -762,7 +763,8 @@ ctf_rollback (ctf_file_t *fp, ctf_snapshot_id_t id)
762763 kind = LCTF_INFO_KIND (fp, dtd->dtd_data.ctt_info);
763764
764765 if (dtd->dtd_data.ctt_name
765- && (name = ctf_strraw (fp, dtd->dtd_data.ctt_name)) != NULL)
766+ && (name = ctf_strraw (fp, dtd->dtd_data.ctt_name)) != NULL
767+ && LCTF_INFO_ISROOT (fp, dtd->dtd_data.ctt_info))
766768 {
767769 ctf_dynhash_remove (ctf_name_table (fp, kind)->ctn_writable,
768770 name);
@@ -831,7 +833,7 @@ ctf_add_generic (ctf_file_t *fp, uint32_t flag, const char *name, int kind,
831833 return (ctf_set_errno (fp, EAGAIN));
832834 }
833835
834- if (ctf_dtd_insert (fp, dtd, kind) < 0)
836+ if (ctf_dtd_insert (fp, dtd, flag, kind) < 0)
835837 {
836838 free (dtd);
837839 return CTF_ERR; /* errno is set for us. */
@@ -1094,8 +1096,7 @@ ctf_add_struct_sized (ctf_file_t *fp, uint32_t flag, const char *name,
10941096 ctf_dtdef_t *dtd;
10951097 ctf_id_t type = 0;
10961098
1097- /* Promote forwards to structs. */
1098-
1099+ /* Promote root-visible forwards to structs. */
10991100 if (name != NULL)
11001101 type = ctf_lookup_by_rawname (fp, CTF_K_STRUCT, name);
11011102
@@ -1132,7 +1133,7 @@ ctf_add_union_sized (ctf_file_t *fp, uint32_t flag, const char *name,
11321133 ctf_dtdef_t *dtd;
11331134 ctf_id_t type = 0;
11341135
1135- /* Promote forwards to unions. */
1136+ /* Promote root-visible forwards to unions. */
11361137 if (name != NULL)
11371138 type = ctf_lookup_by_rawname (fp, CTF_K_UNION, name);
11381139
@@ -1168,7 +1169,7 @@ ctf_add_enum (ctf_file_t *fp, uint32_t flag, const char *name)
11681169 ctf_dtdef_t *dtd;
11691170 ctf_id_t type = 0;
11701171
1171- /* Promote forwards to enums. */
1172+ /* Promote root-visible forwards to enums. */
11721173 if (name != NULL)
11731174 type = ctf_lookup_by_rawname (fp, CTF_K_ENUM, name);
11741175
--- a/libctf/ctf-impl.h
+++ b/libctf/ctf-impl.h
@@ -399,7 +399,7 @@ extern void ctf_list_prepend (ctf_list_t *, void *);
399399 extern void ctf_list_delete (ctf_list_t *, void *);
400400 extern int ctf_list_empty_p (ctf_list_t *lp);
401401
402-extern int ctf_dtd_insert (ctf_file_t *, ctf_dtdef_t *, int);
402+extern int ctf_dtd_insert (ctf_file_t *, ctf_dtdef_t *, int flag, int kind);
403403 extern void ctf_dtd_delete (ctf_file_t *, ctf_dtdef_t *);
404404 extern ctf_dtdef_t *ctf_dtd_lookup (const ctf_file_t *, ctf_id_t);
405405 extern ctf_dtdef_t *ctf_dynamic_type (const ctf_file_t *, ctf_id_t);
--- a/libctf/ctf-open.c
+++ b/libctf/ctf-open.c
@@ -765,7 +765,7 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
765765 for (id = 1, tp = tbuf; tp < tend; xp++, id++)
766766 {
767767 unsigned short kind = LCTF_INFO_KIND (fp, tp->ctt_info);
768- unsigned short flag = LCTF_INFO_ISROOT (fp, tp->ctt_info);
768+ unsigned short isroot = LCTF_INFO_ISROOT (fp, tp->ctt_info);
769769 unsigned long vlen = LCTF_INFO_VLEN (fp, tp->ctt_info);
770770 ssize_t size, increment, vbytes;
771771
@@ -787,7 +787,7 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
787787
788788 if (((ctf_hash_lookup_type (fp->ctf_names.ctn_readonly,
789789 fp, name)) == 0)
790- || (flag & CTF_ADD_ROOT))
790+ || isroot)
791791 {
792792 err = ctf_hash_define_type (fp->ctf_names.ctn_readonly, fp,
793793 LCTF_INDEX_TO_TYPE (fp, id, child),
@@ -804,6 +804,9 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
804804 break;
805805
806806 case CTF_K_FUNCTION:
807+ if (!isroot)
808+ break;
809+
807810 err = ctf_hash_insert_type (fp->ctf_names.ctn_readonly, fp,
808811 LCTF_INDEX_TO_TYPE (fp, id, child),
809812 tp->ctt_name);
@@ -812,6 +815,12 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
812815 break;
813816
814817 case CTF_K_STRUCT:
818+ if (size >= CTF_LSTRUCT_THRESH)
819+ nlstructs++;
820+
821+ if (!isroot)
822+ break;
823+
815824 err = ctf_hash_define_type (fp->ctf_structs.ctn_readonly, fp,
816825 LCTF_INDEX_TO_TYPE (fp, id, child),
817826 tp->ctt_name);
@@ -819,23 +828,27 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
819828 if (err != 0)
820829 return err;
821830
822- if (size >= CTF_LSTRUCT_THRESH)
823- nlstructs++;
824831 break;
825832
826833 case CTF_K_UNION:
834+ if (size >= CTF_LSTRUCT_THRESH)
835+ nlunions++;
836+
837+ if (!isroot)
838+ break;
839+
827840 err = ctf_hash_define_type (fp->ctf_unions.ctn_readonly, fp,
828841 LCTF_INDEX_TO_TYPE (fp, id, child),
829842 tp->ctt_name);
830843
831844 if (err != 0)
832845 return err;
833-
834- if (size >= CTF_LSTRUCT_THRESH)
835- nlunions++;
836846 break;
837847
838848 case CTF_K_ENUM:
849+ if (!isroot)
850+ break;
851+
839852 err = ctf_hash_define_type (fp->ctf_enums.ctn_readonly, fp,
840853 LCTF_INDEX_TO_TYPE (fp, id, child),
841854 tp->ctt_name);
@@ -845,6 +858,9 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
845858 break;
846859
847860 case CTF_K_TYPEDEF:
861+ if (!isroot)
862+ break;
863+
848864 err = ctf_hash_insert_type (fp->ctf_names.ctn_readonly, fp,
849865 LCTF_INDEX_TO_TYPE (fp, id, child),
850866 tp->ctt_name);
@@ -855,6 +871,10 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
855871 case CTF_K_FORWARD:
856872 {
857873 ctf_names_t *np = ctf_name_table (fp, tp->ctt_type);
874+
875+ if (!isroot)
876+ break;
877+
858878 /* Only insert forward tags into the given hash if the type or tag
859879 name is not already present. */
860880 if (ctf_hash_lookup_type (np->ctn_readonly, fp, name) == 0)
@@ -881,6 +901,9 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
881901 case CTF_K_VOLATILE:
882902 case CTF_K_CONST:
883903 case CTF_K_RESTRICT:
904+ if (!isroot)
905+ break;
906+
884907 err = ctf_hash_insert_type (fp->ctf_names.ctn_readonly, fp,
885908 LCTF_INDEX_TO_TYPE (fp, id, child),
886909 tp->ctt_name);