Print cgraph_uid in function header
[official-gcc.git] / gcc-4_6-mobile-vtable-security / ChangeLog.vtable-security
blob4c4d9f98eda6f8c90c4f5942695c084f7e3cea81
1 2013-02-04  Caroline Tice <cmtice@google.com>
3         * gcc/cp/g++spec.c: (lang_specific_driver): Add new value to
4         saw_vtable_verify for preinit option; increase the size of num_args if
5         appropriate; only add the vtable verification linker options if the
6         linker will actually be called.
7         * libstdc++-v3/libsupc++/vtv_rts.cc (dl_iterate_phdr_callback):  Add
8         check for empty name-stirng with non-zero address (for
9         linux-vdso.so.1); change vtv_assert (fd != 1) to an if-condition.
11 2013-01-30  Caroline Tice  <cmtice@google.com>
13         * libstdc++-v3/configure:  Add vtv_start.o and vtv_end.o to
14         predep_objects and postdep_objects, respectively.
15         * libstdc++-v3/libstupc++/vtv_rts.cc (ReadPersistent):  New function.
16         (ReadFromOffset):  New function.
17         (log_memory_protection_data):  New function.
18         (dl_iterate_phdr_callback):  Completely rewrite function, to find the
19         info record's corresponding file on disk, open it, read the section
20         header information to see if it has a ".vtable_map_vars" section; if
21         so, to read the section header information, use that to find the
22         section's start address and size in memory, and call mprotect to
23         change the protections accordingly on those pages.
24         * libstdc++-v3/libsupc++/vtv_utils.h:  Change the definition of
25         VTV_PROTECTED_VARS_SECTION to ".vtable_map_vars".
26         * libgcc/config.host:  Add vtv_start.o and vtv_end.o to extra_parts.
27         * libgcc/Makefile.in:   Add definitions for building vtv_start.o and
28         vtv_end.o
29         * libgcc/vtv_start.c: New file.
30         * libgcc/vtv_end.c: New file.
31         * gcc/cp/g++spec.c: Add -u_vtable_map_vars_start and
32         -u_vtable-map_vars_end options.
33         * gcc/cp/vtable-class-hierarchy.c (vtable_find_or_create_map_decl):
34         Change sect_name to ".vtable-map_vars".
35         * gcc/tree-vtable-verify.c (verify_bb_vtables):  Eliminate unused
36         variable, prev_use.  Small cleanups.
37         * gcc/varasm.c (assemble_variable):  Update condition for finding
38         and handling variables with the section ".vtable_map_vars".
39         (default_section_type_flags):  Make sure things in ".vtable_map_vars"
40         section get the SECTION_LINKONCE flag.
41         * gcc/config.gcc:  Add vtv_start.o and vtv_end.o to extra_parts.
42         * gcc/config/i386/linux.h:  Add vtv_end.o to ENDFILE_SPEC if the flag
43         "-fvtable-verify=" is present.
44         * gcc/config/i386/linux64.h: Ditto.
45         * gcc/config/gnu-user.h:  Add vtv_start.o to
46         GNU_USER_TARGET_STARTFILE_SEPC if the flag "-fvtable_verify=" is
47         present; Add vtv_end.o to GNU_USER_TARGET_ENDFILE_SPEC if the flag
48         "-fvtable-verify=" is present.
50 2013-01-28  Caroline Tice  <cmtice@google.com>
52         * gcc/cp/vtable-class-hierarchy.c (record_register_pairs):
53         Remove code to calculate mangled name of class; pass class
54         type directly to vtbl_map_get_node.
55         (register_vptr_fields): Fix white spaces.
56         (find_graph_node):  Remove code do calculate mangled name of
57         class; pass class type directly to vtbl_map_get_node.
58         (write_out_counters):  New function.
59         (vtv_generate_init_routine):  Add call to write_out_counters,
60         if VTV_COUNT is defined.
61         (vtbl_find_or_create_map_decl): Remove qualifiers on class type
62         before getting the mangled name (for creating vtable map
63         variable). Pass class type directly to vtbl_map_get_node. Fix
64         comments.
65         (vtv_save_base_class_info):  Fix white spaces.
66         * gcc/tree-vtable-verify.c (total_num_virtual_calls,
67         total_num_verified_vcals):  New global variables.
68         (vtbl_map_get_node):  Change parameter to type class, rather
69         than mangled name of class.  Temporarily remove any type
70         qualifiers on the class before generating the mangled name.
71         (find_of_create_vtbl_map_node):  Temporarily remove any type
72         qualifiers on the class type before generating the mangled name.
73         (reset_type_qualifiers):  New function.
74         (verify_bb_vtables):  Increment total_num_virtual_calls and
75         total_num_verified_vcalls as appropriate. Remove code to calculate
76         mangled class name; pass class type directly to vtbl_map_get_node.
77         * gcc/tree-vtable-verify.h (total_num_virtual_calls,
78         total_num_verified_vcalls):  New extern global variable decls.
79         (reste_type_qualifiers):  New extern function decl.
81 2013-01-22  Luis Lozano  <llozano@google.com>
83         * libstdc++-v3/libsupc++/vtv_utils.cc: create the logs under
84         /var/log/chrome if it exists. This location does not dissapear
85         after a reboot.
87 2012-12-18  Luis Lozano  <llozano@google.com>
89         * gcc/tree-vtable-verify.c: temporary workaround for missed
90         verification assert.
91         * libstdc++-v3/libsupc++/vtv_malloc.cc: cleaned up warning
92         related to VTV_DEBUG macro
93         * libstdc++-v3/libsupc++/vtv_rts.cc:
94         Fixed use of VTV_NO_ABORT macro. The way it was used before the
95         compiler still saw a call to __vtv_really_fail which had the
96         "noreturn" attribute which can cause problems during optimization.
97         (vtv_fail): Dont open/close stty. Just send message to fd 2 (stderr).
98         Fix issue in printing the value of the set handle.
99         (__vtv_verify_fail): Fixed issue with printing value of set handle.
100         Added \n to the message passed to vtv_fail.
102 2012-11-30  Luis Lozano  <llozano@google.com>
104         * gcc/BASE-VER: changed 4.6.x to 4.6.3. Not having this confuses 
105         some packages.
106         * gcc/cp/vtable-class-hierarchy.c: Mark global static function pointer 
107         tress with GTY.
108         (init_functions): clean up types of runtime functions, remove
109         unnecessary arguments and add new function for initializations of sets
110         (register_vptr_fields): clean up some warnings for unused variables.
111         Put creation of string constants under VTV_DEBUG for contants that are
112         only used under that mode.
113         Reduce number of calls to build_string by factoring call out of the loop.
114         This could be reduced further by keeping track of what strings have 
115         already been built.
116         (register_other_binfo_vtables): clean up calls to RegisterPair.
117         (guess_num_vtable_pointers): modify to use size_t instead of int.
118         (register_all_pairs): create runtime debug strings only under 
119         VTV_DEBUG. 
120         Factor creation of invariant string out of the loop.
121         (create_undef_reference_to_vtv_init): change name of argument to 
122         reflect the fact that init routine is not doing only registration of 
123         pairs anymore.
124         (vtv_string_hash): new routine to calculate a string hash to use as 
125         argument to InitSet.
126         (init_all_sets): new routine to create calls to initialize of 
127         pointers to vtable sets.
128         (vtv_register_class_hierarchy_information): add call to init_all_sets.
129         Changed name of initialization routine body. 
130         (vtv_generate_init_routine): changed name of init routine body 
131         variable.
132         (vtable_find_or_create_map_decl): create string name for symbol only 
133         when needed. 
134         Change visibility of vtable map symbol to HIDDEN to improve performance.
135         * gcc/tree-vtable-verify.c: mark static tree's as GC roots
136         (verify_bb_vtables): remove unnecessary conditional. 
137         Clean upcall to verifyvtable.
138         (build_vtable_verify_fndecl): clean up number of arguments and 
139         argument types to verify vtable call
140         Mark the vtableverify function as pure
141         Add define for linking and calling this statically (VTV_STATIC_VERIFY,
142         which is experimental for now)
143         * libstdc++-v3/config/abi/pre/gnu.ver: removed the vtable_map variables
144         from the version file. These dont need to be GLOBAL anymore since we
145         doing our own symbol unification.
146         * libstdc++-v3/libsupc++/vtv_init.cc: removed unneded trace message 
147         guarded under wrong macro. If we want this back it should go into a file
148         and guarded by its own guard variable.
149         Added experimental code or VTV_STATIC_VERIFY. This should not be commited
150         to upstream. For now, just allows us to play experiments. If we are going
151         to do this we need to re-architect.
152         * libstdc++-v3/libsupc++/vtv_fail.h: clean up prototype. 
153         * libstdc++-v3/libsupc++/vtv_malloc.cc: change calls to vtv_open_log to
154         stop passing the dir where the log should be created.
155         * libstdc++-v3/libsupc++/vtv_rts.cc: 
156         Cleanup of what static variables need to be protected and which ones need 
157         to be under VTV_DEBUG.
158         Added utility classes and template definitions to create an 
159         insert_only_hash_map map to keep track of the unified symbols for sets.
160         Reorganize routines so that the VTV_DEBUG versions go together.
161         Added VTV_NO_ABORT macro to control abort() behavior.
162         (log_set_stats): stop specifying directory for log
163         (__VLTInitSetSymbol): new routine to initialize symbol map (from symbol to 
164         pointer-to-vtable-set-handle) and the set handle itself. There are 2 
165         versions of this routine, one with debug information and and verification 
166         enable and the other for faster execution with no support for debugging.
167         (__VLTRegisterPairDebug): removed unnecessary arguments, cleaned up argument
168         list. 
169         Modified to consider the case where the handle is not a pointer to the 
170         vtable set but a pointer to the handle.
171         * libstdc++-v3/libsupc++/vtv_rts.h: added prototype for __VLTInitSetSymbol*
172         cleaned up arguments.
173         * libstdc++-v3/libsupc++/vtv_set.h: incorporated latest version.
174         Added macro for VOLATILE markers and removed current volatiles. This are not
175         need now but can easily be added back with the MACRO
176         Added header guards.
177         * libstdc++-v3/libsupc++/vtv_map.h:
178         New file. Implementation of an insert only hashmap that uses pre-computed
179         hash values. Implemented by Geoff Pike.
180         * libstdc++-v3/libsupc++/vtv_stubs.cc: Cleaned up arguments and added 
181         prototype for __VLTInitSetSymbol.
182         * libstdc++-v3/libsupc++/vtv_utils.cc: Changed logs creation so that we 
183         always put logs in the same directory
184         * libstdc++-v3/libsupc++/vtv_utils.h: Changed VTV_DEBUG_ASSERT so that 
185         it will only assert under VTV_DEBUG
187 2012-11-13  Caroline Tice  <cmtice@google.com>
189         * gcc/tree-vtable-verify.c (is_vtable_assignment_stmt):  Remove
190         unnecessary loop and test from end of function.
191         (verify_bb_vtables):  Add prev_use; improve comments; clean up code
192         in loop that searches back through def chain.  Add code to look for
193         insertion point the the same basic block as the def stmt.  Clean up the
194         code that looks for the statically declared type of the object.  Change
195         some conditionals to assert statements.  Replace tabs with spaces.
197 2012-10-29  Luis Lozano  <llozano@google.com>
199         * gcc/cp/vtable-class-hierarchy.c (register_vptr_fields): Fixed issue
200         with string constants passed to runtime rutines
201         * gcc/tree-vtable-verify.c (verify_bb_vtables): ditto
203 2012-10-17  Caroline Tice  <cmtice@google.com>
205         * libstdc++-v3/libsupc++/vtv_rts.cc (log_error_message):  Add ability
206         to output backtrace, based on a new boolean parameter.  Use
207         backtrace_symbols_fd rather than backtrace_symbols, to remove any
208         memory allocation.
209         (log_backtrace): Deleted function.
210         (__vtv_verify_fail_debug):  Added boolean parameter to calls  to
211         log_error_message; changed call to log_backtract into call to
212         log_error_message with true.
213         (__vtv_verify_fail): Ditto.
215 2012-10-16  Luis Lozano  <llozano@google.com>
216         * gcc/cp/vtable-class-hierarchy.c:
217         Fixed lines longer than 80 chars.
218         (register_all_pairs): keep track of when RegisterPair calls where
219         added.
220         (vtv_register_class_hierarchy_information): modified so that
221         we dont generate the calls to change permission or the undefined
222         symbol to vtv_init unless we made some calls to RegisterPair
223         * libstdc++-v3/libsupc++/vtv_init.cc:
224         Fixed lines longer than 80 chars
225         * libstdc++-v3/libsupc++/vtv_rts.cc:
226         Fixed lines longer than 80 chars
228 2012-10-09  Luis Lozano  <llozano@google.com>
230         * vtable-class-hierarchy.c (create_undef_reference_to_vtv_init):
231         Added this routine to generate a reference to a symbol defined in
232         vtv_init.a so that if the link is done without vtv_init.a the linker
233         will complain.
234         (vtv_generate_init_routine): Add call to generate the undef symbol
235         only when using -fvtable-verify=std.
236         * gcc/tree-vtable-verify.c (verify_bb_vtables): removed stale comment
237         and minor clean up.
238         * libstdc++-v3/libsupc++/vtv_init.cc: Added definition of symbol so
239         that references from object files built with -fvtable-verify=std can
240         be resolved. Symbol must be "hidden" to make sure it is not resolving
241         a reference from other load module.
242         * libstdc++-v3/libsupc++/vtv_rts.cc: fixed couple of warnings.
244 2012-10-09  Caroline Tice  <cmtice@google.com>
246         * libstdc++-v3/libsupc++/vtv_rts.cc (__vtv_verify_fail_debug):  New
247         function, for putting out extra debug information when a fail occurs.
248         (debug_log_message):  New global variable, for debug messages.
249         (load_debug_log_message):  New function.
250         (__VLTVerifyVtablePointerDebug):  Add call to load_debug_log_message;
251         call __vtv_verify_fail_debug instead of __vtv_verify_fail.
252         (log_error_message):  New function; write error/debug info to log file.
253         (log_backtrace):  Generate backtrace info and write to log file.
254         (__vtv_verify_fail):  Write failure information to log file, before
255         calling vtv_fail.
256         * gcc/tree-vtable-verify.c (verify_bb_vtables):  Loop through entire
257         basic block looking for virtual calls, instead of stopping after first
258         virtual call.  Also search through def_stmt chain to find vptr field
259         assignment statement; use type from 'this' object, or from rhs of
260         vptr field assignment statement to find type for vtable map variable.
262 2012-10-02  Caroline Tice  <cmtice@google.com>
264         * libstdc++-v3/config/abi/pre/gnu.ver (GLIBCXX_3.4.16): Modify name
265         format of vtable map variables, in the global symbol export list.
266         * gcc/cp/vtable-class-hierarchy.c (vtable_find_or_create_map_decl):
267         Modify format of vtable map variable names, to demangle nicely.
268         * gcc/tree-vtable-verify.c (verify_bb_vtables):  Remove some dead code.
270 2012-09-24  Luis Lozano  <llozano@google.com>
272         * gcc/cp/class.c: Change to only save a reference to the class type 
273         instead of creating all the hierarchy information at this point. This
274         change is necessary to support pre-compiled headers.
275         * gcc/cp/config-lang.in: Added list of vtv files with GC types.
276         * gcc/cp/cp-tree.h: remove vtv_save_base_clas_info from list of extern
277         symbols and replace with vtv_save_class_info (save only minimal info)
278         * gcc/cp/decl2.c (cp_write_global_declarations): Before computing the
279         transitive closure, calculate the hierarchy information from the 
280         information saved during parsing. Also removed some stale comments.
281         * gcc/cp/g++spec.c (lang_specific_driver): modified driver to add 
282         the vtv_init library whenever the invocation is doing a link and 
283         -fvtable-verify=std is being done. Dont add it in the case where 
284         -fvtalbe-verify=preinit is used since the initialization mechanism in 
285         there should not use vtv_init.
286         * gcc/cp/pt.c (mark_class_instantiated): Save info about class in 
287         the case of explicitly instantiated template. This will later be used
288         in "cp_write_global_declarations".
289         * gcc/cp/vtable-class-hierarchy.c: clean up the GTY markers. Only set
290         it to the minimal set of vars.
291         Also do some code cleanup, add a few asserts.
292         (vtv_save_class_information): new routine. Save minimal information
293         about a class (a pointer to it) into a TREE_CHAIN to be recovered
294         later in the compilation. This is needed to support pre-compiled 
295         headers. In this way only minimal information about VTV is stored
296         in the precompiled headers and we only need to mark very few 
297         things with the GC annotations "GTY".
298         (vtv_recover_class_info): Recover VTV interesting classes from 
299         the tree chain and construct the class hierarchy from them.
300         * gcc/tree-vtable-verify.c: cleaned up type GTY annotations. Some 
301         code cleanup and adding of assertions.
302         (find_or_create_vtbl_map_node): routine renamed from "vtbl_map_node 
303         because of name conflict with another type.
304         * gcc/tree-vtable-verify.h: renamed vtbl_map_node to 
305         find_or_create_vtbl_map_node.
306         * libstdc++/libsupc++/vtv_rts.cc some code cleanup to integrate 
307         new implementation of set.
308         Also added the declarations of stats vars required for the set.
309         (log_set_stats): new routine to add to a lot the stats from sets.
310         * libstdc++/libsupc++/vtv_set.h incorporated recent version of 
311         vtable sets that includes changes for generation of statistics.
312         There is one more recent with a fix for the generation of logs 
313         but I have not incorporated that one yet.
315 2012-09-06  Caroline Tice  <cmtice@google.com>
317         * libstdc++-v3/config/abi/pre/gnu.ver:  Add __VLTRegisterPairDebug
318         and __VLTVerifyVtablePointerDebug to the list of exported functions.
320 2012-09-06  Caroline Tice  <cmtice@google.com>
322         * libstdc++-v3/libsupc++/vtv_rts.h:  Add missing comma in function
323         declaration.
325 2012-08-30  Caroline Tice  <cmtice@google.com>
327         * libstdc++-v3/libsupc++/Makefile.in:  Re-generated Makefile.in
328         from the new Makefile.am (see commit below); committing the changed
329         file.
331 2012-08-30  Luis Lozano  <llozano@google.com>
333         * libstdc++-v3/libsupc++/Makefile.am: removed vtv_threaded_hash.cc
334         * libstdc++-v3/libsupc++/vtv_threaded_hash.cc: removed this code. It
335         is not needed anymore.
336         * libstdc++-v3/libsupc++/vtv_rts.cc: simplified dlopen handling code.
337         Reduced number of locks used from 2 to 1.
338         (initialize_change_permissions_mutexes): Get rid of unnecessary code
339         (__VLTChangePermission): ditto. We are simplifying the code to avoid
340         having another unprotected variable. In the new code the only
341         unprotected variable is the "change_permissions_lock". It is not clear
342         how this could be attacked but at least in this code once the code is
343         grabbed the code will always lock the memory again.
344         (PrintStackTrace): removed this unneded routine.
345         * libstdc++-v3/libsupc++/vtv_stubs.cc: cleaned up to avoid some
346         warnings and reorganized a bit.
348 2012-08-28  Luis Lozano  <llozano@google.com>
350         * gcc/cp/vtable-class-hierarchy.c (init_functions): cleaned up extra
351         arguments to VerifyRegisterPair.
352         Also, fixed issue in signature for VLTRegisterPair.
353         (guess_num_vtable_pointers): modified to always return a power of 2
354         number. This is required by the new set implementation
355         (register_all_pairs): code to call one of two versions of
356         VerifyRegisterPairs (debug and non-debug)
357         * libstdc++-v3/libsupc++/vtv_rts.cc (__VLTRegisterPairDebug): created
358         this new routine to keep the debug/tracing functionality
359         (__VLTRegisterPair):Cleaned up version of RegisterPair
360         * libstdc++-v3/libsupc++/vtv_rts.h: added declararions for the debug
361         and non-debug versions of RegisterPair and VerifyVtablePointer
362         * ibstdc++-v3/libsupc++/vtv_set.h: incorported new version of vtv_set.h
363         Replaced assert by VTV_DEBUG_ASSERT so that we can turn off asserts in
364         the libstdc++ library build.
365         * libsupc++/vtv_utils.h: Map DEBUG_ASSERT to (void) so that we can
366         see the best performance numbers from the new set.
368 2012-08-24  Caroline Tice  <cmtice@google.com>
370         * libstdc++-v3/libsupc++/Makefile.in: Re-generated file from
371         new Makefile.am (for libvtv_stubs library).
372         * libstdc++-v3/libsupc++/vtv_rts.h (__VLTRegisterPair):  Added
373         function declaration.
374         (__VLTVerifyVtablePointer):  Added function declaration.
375         * libstdc++-v3/libsupc++/vtv_stubs.cc:  New file. Implements
376         stub versions of __VLTChangePermission, __VLTRegisterPair,
377         and __VLTVerifyVtablePointer.
378         * libstdc++-v3/libsupc++/Makefile.am (toolexeclib_LTLIBRARIES):
379         Added libvtv_stubs.la to library list.
380         (vtv_stubs_sources): New definition.
381         (libvtv_stubs_la_sources):  New definition.
382         (vtv_stubs.lo, vtv_stubs.o): New build rules.
384 2012-08-24  Luis Lozano  <llozano@google.com>
386         * gcc/cp/vtable-class-hierarchy.c (vtable_find_or_create_map_decl):
387         When creating the vtv_map variables dont mark them as read-only.
388         This confuses the gold linker and they dont get put into the relro
389         segment.
391 2012-08-24  Caroline Tice  <cmtice@google.com>
393         * gcc/common.opt (VTV_NO_PRIORITY): Add string "none" for users
394         to specify this priority (i.e. turn of vtable verification).
396 2012-08-21  Luis Lozano  <llozano@google.com>
398         * libstdc++-v3/libsupc++/vtv_utils.cc: stop using deprecated 
399         sys_errlist. Replaced it with strerror.
401 2012-08-21  Caroline Tice  <cmtice@google.com>
403         * libstdc++-v3/libsupc++/vtv_rts.cc:  (fcntl.h, vtv_fail.h):  Two
404         new include statements.
405         (__fortify_fail): New extern "C" extern function declaration.
406         (__VLTVerifyVtablePointerDebug):  Replace calls to PrintStackTrace and
407         abort with call to __vtv_verify_fail. Print message if
408         __vtv_verify_fail returns, i.e. secondary verification succeeded.
409         (__VLTVerifyVtablePointer):  Replace calls to PrintStackTrace and
410         abort with call to __vtv_verify_fail.
411         (__vtv_really_fail):  New function.
412         (__vtv_fail):  New function.
413         (__vtv_verify_fail):  New function.
414         * libstdc++-v3/libsupc++/vtv_fail.h:  New header file.
415         * libstdc++-v3/config/abi/pre/gnu.ver (GLIBCXX_3.4.16):  Add
416         __vtv_verify_fail and __vtv_really_fail to the exported function
417         list.
419 2012-08-20  Luis Lozano  <llozano@google.com>
421         * libstdc++-v3/libsupc++/Makefile.am: Added new file vtv_utils.cc
422         * libstdc++-v3/libsupc++/vtv_malloc.cc (VTV_malloc_protect): use new
423         log routines.
424         * libstdc++-v3/libsupc++/vtv_malloc.cc (VTV_malloc_dump_stats): new
425         routine to dump stats to log file using new log routines.
426         * libstdc++-v3/libsupc++/vtv_malloc.h: Added prototypes for new
427         dumping routine
428         * libstdc++-v3/libsupc++/vtv_rts.cc (log_register_pairs): change to use
429         new logging routines
430         * libstdc++-v3/libsupc++/vtv_rts.cc (__VLTRegisterPair): clean up
431         redundant contidion.
432         Change to use new logging routines.
433         * libstdc++-v3/libsupc++/vtv_utils.h: add prototypes for new logging
434         routines. The new logging routines use low level file access routines
435         and avoid calling malloc to avoid changing the order of dlopen calls.
436         We dont want to disturb the behavior of the initailization of the
437         program being logged.
438         * libstdc++-v3/libsupc++/vtv_utils.CC: new file with new logging
439         routines.
441 2012-08-13  Luis Lozano  <llozano@google.com>
443         * libstdc++-v3/libsupc++/vtv_utils.h: added new header for common
444         utilities. It includes now the macross for assert and runtime error.
445         Also the macros to protect static variables.
446         * libstdc++-v3/libsupc++/vtv_set.h: implementation of new hash set.
447         Main differences are this hash set uses "open addressing" and
448         provides implementation of a singleton set. Should definetly consume
449         less memory and should also be faster (written by Geoff Pike)
450         * libstdc++-v3/libsupc++/vtv_init.cc (__VLTunprotect): cleaned
451         up some sporious comments
452         * libstdc++-v3/libsupc++/vtv_init.cc (__VLTprotect): cleaned
453         up some sporious comments
454         * libstdc++-v3/libsupc++/vtv_malloc.cc: since code moved from
455         vtv_malloc.h to vtv_utils.h, include vtv_utils.h.
456         Start using new assert macros.
457         * libstdc++-v3/libsupc++/vtv_malloc.h: removed unncessary
458         "extern C".
459         Moved some common macros that are being used by all the vtv
460         code to vtv_utils.h.
461         * libstdc++-v3/libsupc++/vtv_rts.cc: since code moved from vtv_malloc.h
462         to vtv_utils.h, include vtv_utils.h.
463         remove unneccessary check for C++ compiler.
464         Define basic types to be used by new hash set implementation.
465         Use gthreads instead of pthreads for portability with libstdc++.
466         (__VLTChangePermission): change code to handle concurrent dlopens. This
467         code still needs work.
468         Added lock to serialize the calls to RegisterPair according to the
469         restrictions of new hash set implementation.
470         (__VLTRegisterPair): modify to use new hash set implementation.
471         Remove unnecessary locking code. RegisterPair calls are now serilized.
472         (__VLTVerifyVtablePointerDebug): Modify to use new hash set
473         (__VLTVerifyVtablePointer): Modify to use new hash set
474         * libstdc++-v3/libsupc++/vtv_threaded_hash.cc: this is now an obsolete
475         file. Used new macros for assert.
476         * libstdc++-v3/libsupc++/vtv_threaded_hash.h: This is now an obsolete
477         file. Used new macros for assert.
479 2010-08-09  Caroline Tice  <cmtice@google.com>
481         * libstdc++-v3/libsupc++/vtv_rts.cc (map_var_mutex):  Move out of
482         __VLTRegisterPair and make this a global static variable.
483         (initialize_mutex_once): New function.
484         (__VLTRegisterPair):  Make map_var_mutex a global static variable;
485         add mutex_once, and use to properly initialize map_var_mutex, if
486         needed. Move VTV_error to vtv_utils.h
488 2012-08-08  Caroline Tice  <cmtice@google.com>
490         * libstdc++-v3/libsupc++/vtv_rts.cc (__VLTRegisterPair): Replace
491         PTHREAD_MUTEX_INITIALIZER with __GTHREAD_MUTEX_INIT or
492         __GTHREAD_MUTEX_INIT_FUNCTION.  Replace pthred_mutex_lock and
493         pthread_mutex_unlock with __thread_mutex_lock and
494         __gthread_mutex_unlock.  Use __gthread_mutex_t for the mutex type.
495         * libstdc++-v3/libsupc++/vtv_threaded_hash.cc (vlt_hash_init_table):
496         Use __gthread_mutex_t for the mutex type.  Replace
497         PTHREAD_MUTEX_INITIALIZER with __GTHREAD_MUTEX_INIT or
498         __GTHREAD_MUTEX_INIT_FUNCTION.
499         (vlt_hash_insert):  Replace pthred_mutex_lock and
500         pthread_mutex_unlock with __thread_mutex_lock and
501         __gthread_mutex_unlock.
502         * libstdc++-v3/libsupc++/vtv_threaded_hash.h:  Remove include for
503         pthread.h. Add includes for <bits/c++config.h> and <ext/concurrence.h>.
504         (struct vlt_hashtable):  Change type of mutex to __gthread_mutex_t.
506 2012-08-06  Caroline Tice  <cmtice@google.com>
508         * gcc/cp/vtable-class-hierarchy.c (vtv_generate_init_routine):
509         Make init function local rather than global.
511 2012-07-26  Caroline Tice  <cmtice@google.com>
513         * libstdc++-v3/libsupc++/vtv_rts.cc (__VLTVerifyVtablePointerDebug):
514         Remove code that says an empty hash table is valid.
515         (__VLTVerifyVtablePointer):  Ditto.
516         * libstdc++-v3/config/abi/pre/gnu.ver: Fix code that exports vtable
517         map variables to look for "__" rather than "." in the name.
518         * gcc/cp/vtable-class-hierarchy.c (register_all_pairs): Remove a line
519         of commented out dead code.
521 2012-07-19  Luis Lozano  <llozano@google.com>
523         * libstdc++-v3/libsupc++/vtv_malloc.cc: moved VTV_assert to header
524         file
525         * libstdc++-v3/libsupc++/vtv_malloc.cc: ditto.
526         * libstdc++-v3/libsupc++/vtv_rts.cc (log_register_pairs): Changed to
527         use snprintf insted of sprintf for better protection.
528         (__VLTRegisterPair): Be consistent about the use of volatile variable
529         * libstdc++-v3/libsupc++/vtv_threaded_hash.cc: Added some assert around
530         the code to help with multi-threaded triaging.
531         (grow_table): make sure that the update of the "data" field is the
532         last thing we do. This is important for consistency in the
533         multithreaded case.
534         (vlt_hash_insert): fix the code to depend only on one field that could
535         have a race condition (table->data). The code is supposed to handle the
536         race condition. This fixes the last know issue regarding
537         multi-threading.
539 2012-07-18  Caroline Tice  <cmtice@google.com>
541         * libstdc++-v3/libsupc++/vtv_rts.cc (__VLTRegisterPair):  Add
542         static mutex variable, protected, and statically initialize it.
543         Add volatile pointer variable to contain address of vtable_map var, to
544         force re-evaluation on second read. Lock mutex before calls
545         vlt_hash_init_table, and unlock it afterwards, to prevent two threads
546         trying to initialize the same vtable map variable at the same time.
547         * libstdc++-v3/libsupc++/vtv_threaded_hash.cc (rehash_elements):
548         Remove unused parameter new_size. Add format to constant when
549         calculating hash mask.
550         (grow_table): Reformat comment.  Increase table size by 1, to allow
551         for hash mask.  Put hash mask in first element of table.  Add hash
552         mask explanatory comments.  Make main table start at second element.
553         Add  format to constant when calculating hash mask.
554         (vlt_hash_init_table):  Ditto.
555         (vlt_hash_insert):  Look for hash mask directly in data table.  Use
556         size rather than hash mask to check if table changed.  Enforce FSF
557         guidelines: indent curly braces and limit lines to 80 chars. Updated
558         some comments.
559         (dump_table_to_file):  Read hash mask from table.
560         * libstdc++-v3/libsupc++/vtv_threaded_hash.h (struct vlt_hashtable):
561         Remove hash_mask field. Make data_size and data volatile.
562         (vlt_hash_find): Only access table pointer once (read and store it);
563         read hash mask directly from table.
565 2012-06-27  Luis Lozano  <llozano@google.com>
567         * libstdc++-v3/libsupc++/vtv_malloc.cc (obstack_chunk_alloc):
568         Fixed merge problem. We were still calling posix_memalign instead
569         of calling mmap.
571 2012-06-25  Luis Lozano  <llozano@google.com>
573         * gcc/cp/vtable-class-hierarchy.c (init_functions): Changed
574         arguments to VLT_ChangePermission. Instead of passing strings
575         like "rw"/"ro", pass integer constants.
576         Removed some unneded code.
577         (vtv_register_class_hierarchy_information): Changed calls to
578         VLT_ChangePermission.
579         (vtable_find_or_create_map_decl): Removed the "." from the
580         vtable map variables identifiers. This dot confuses the debugger
581         when trying to examine these variables.
582         Put vtable_map variables into data.rel.ro so that they can be
583         protected and unprotected (code written by Caroline)
584         * gcc/tree-vtable-varify.c (verify_bb_vtables): Removed the "."
585         from the vtable_map variable names.
586         * gcc/varasm.c (assemble_variable): For ELF object format,
587         mark the vtable_map variables as LINKONCE.
588         * libstdc++/libsupc++/Makefile.am: Force a dependency between
589         vtv_int.cc and vtv_rts.h
590         * libstdc++/libsupc++/Makefile.in: generated file from
591         Makefile.am with automake.
592         * libstdc++/libsupc++/vtv_init.cc: Added copyright header.
593         Include new header "vtv_rts.h", to facilitate calls to
594         __VLTChangePermission with simplified arguments.
595         * libstdc++/libsupc++/vtv_malloc.cc: Protected static
596         variables that are not debug related by putting them into
597         data.rel.ro sections.
598         (vtv_protect): change name to vtv_malloc_protect.
599         (vtv_unprotect): change name to vtv_malloc_unprotect.
600         (vtv_malloc_init): moved static variable to global scope to
601         put it together with other protect variables.
602         * libstdc++/libsupc++/vtv_malloc.h:
603         changed name of vtv_protect and vtv_unprotect
604         Created macro to put a static variable in .data.rel.ro section
605         with name ".data.rel.ro.vtable_vars". Should probably put this
606         into a separate base header.
607         * libstdc++/libsupc++/vtv_rts.h:
608         Protected non debug variables by using new macro for this purpose.
609         (dl_iterate_phdr_callback): call back routine that is called by
610         dl_iterate_phdr for each segment found in each load module. This
611         routine finds the rel.ro segment and protects/unprotects it according
612         to the argument passed.
613         (vtv_unprotected_vtable_vars): new routine that unprotecs all
614         static vars used by vtable verification
615         (vtv_protect_vtable_vars): new routine that protects all static
616         vars used by vtable verification.
617         (__VLTChangePermission): Changed arguments from string and length
618         to integer value.
619         Modified to add calls to protect static variables used by vtable
620         verification on top of protection to malloc'ed memory.
621         (__VLTRegisterPair): cleaned up some code.
622         * libstdc++/libsupc++/vtv_threaded_hash.cc (rehash_elements):
623         removed unnecessary check for NULL.
624         (vlt_hash_insert): Modified to fix possible problem in multithreaded
625         case.
626         Modified to try to get rid of second call to vlt_bucket_find which
627         can be expensive. Did this to try to recover start up degradation
628         in chrome.
629         * libstdc++/libsupc++/vtv_threaded_hash.h (vlt_bucket_find):
630         added new argument to avoind searching in the whole list. Only search
631         until the point specified by argument.
633 2012-06-15  Luis Lozano  <llozano@google.com>
635         * gcc/tree-vtable-verify.c (verify_bb_vtables): Modify to call
636         a different VerifyVtablePointer if compiled with VTV_DEBUG.
637         If debug version takes more arguments and prints more debug
638         information.
639         * libstdc++-v3/libsupc++/vtv_rts.cc
640         (__VLTVerifyVtablePointerDebug): New routine. It is actually
641         a rename of the old routine. This version is called when
642         tree-vtable-verify.c is built with VTV_DEBUG.
643         (__VLTVerifyVtablePointer): cleaned up this routine to improve
644         performance.
645         * libstdc++-v3/libsupc++/vtv_threaded_hash.cc
646         (hash_pointer): moved to vtv_threaded_hash.h so that it can be
647         inlined
648         (bucket_find): moved to vtv_threaded_hash.h so that it can be
649         inlined
650         (dump_bucket_info): fixed a warning.
651         * libstdc++-v3/libsupc++/vtv_threaded_hash.h
652         (vlt_hash_pointer): moved here and marked as static inline.
653         (vlt_bucket_find): moved here and marked as static inline. Removed
654         some unnecessary code.
655         (vlt_hash_find): moved here and marked as static inline. cleaned
656         up for performance
658 2012-06-14  Caroline Tice  <cmtice@google.com>
660         * libstdc++-v3/libsupc++/vtv_rts.cc: Added copyright comments.
661         (__VLTChangePermission):  Changed type of first parameter from
662         "const char *" to "char *".
663         * libstdc++-v3/libsupc++/vtv_malloc.h: Added copyright comments.
664         * libstdc++-v3/libsupc++/vtv_threaded_hash.cc: Added copyright
665         comments.
666         (grow_table):  Added comment warning about mutex lock. Removed
667         calls to pthread_mutex_lock and pthread_mutex_unlock.  Removed call
668         to memset that initialized new_data to zero.
669         (access):  Deleted function.
670         (vlt_hash_init_table):  Compare size hint to REHASH_LIMIT times
671         initial_size rather than just initial size.  Make use of size hint
672         to try to create initial table closer to final size (reducing the
673         number of rehashes).
674         (vlt_hash_insert):  Entirely re-wrote function; removed call to access.
675         Updated pthread locking.
676         (vlt_hash_find): Entirely re-wrote function; removed call to access.
677         Made reads fast and lock-free.
678         * libstdc++-v3/libsupc++/vtv_malloc.cc: Added copyright comments.
679         * libstdc++-v3/libsupc++/vtv_threaded_hash.h: Added copyright comments.
680         * gcc/cp/vtable-class-hierarchy.c
681         (vtv_register_class_hierarchy_information): Insert calls to
682         __VLTChangePermission directly into initialization routine, if the
683         function is going into the preinit array.
685 2012-06-11  Caroline Tice  <cmtice@google.com>
687         * libstdc++-v3/libsupc++/vtv_rts.cc: Modify include to include
688         "vtv_threaded_hash.h" instead of "threaded-hash.h".
689         (__VLTRegisterPair):  Add size_hint parameter.  Pass size_hint to
690         vlt_hash_init_table.
691         * libstdc++-v3/libsupc++/vtv_threaded_hash.cc (vlt_hash_init_table):
692         Modify to take size_hint parameter.  Use size_hint to possibly enlarge
693         initial table size.
694         * libstdc++-v3/libsupc++/vtv_threaded_hash.h (vlt_hash_init_table):
695         Add int param to function declaration.
696         * libstdc++-v3/config/abi/pre/gnu.ver (GLIBCXX_3.4.16) Change _VLT...
697         functions to use wildcards, to allow parameters to change without
698         affecting the function symbol exports.
699         * gcc/cp/vtable-class-hierarchy.c (init_functions):  Add extra int arg
700         for vlt_register_pair_fndecl, to allow for new size hint.
701         (register_vptr_fields):  Add new hint varable, initialize it to zero, and
702         pass it to calls to __VLTRegisterPair.
703         (register_other_binfo_vtables):  Ditto.
704         (guess_num_vtable_pointers):  New function.
705         (register_all_pairs):  Add size_hint local variabler, and initialize
706         it with call to guess_num_vtable_pointers.  Pass the size_hint to calls
707         to __VLTRegisterPair.
709 2012-06-08  Luis Lozano  <llozano@google.com>
711         * gcc/cp/cp-tree.h: added some prototypes so that we can move some
712         code into vtable-class-hierarchy.
713         * gcc/cp/decl2.c: made start_objects finish_objects availabe to use
714         outside this file
715         (cp_write_global_declarations): move the code related to vtable-verify
716         to the vtable-class-hierarchy and did some cleanup
717         * gcc/cp/vtable-class-hierarchy.c: move the code to generate the
718         register_pairs into this file
719         (vtv_register_class_hierarchy_information): modified to stop calling
720         the routines to protect and unprotect the memory used. These are moved
721         to a special object file that will only be called once per module.
722         (vtv_generate_init_routine): new routine that contains the code moved
723         from decl2.c
724         * gcc/temp-libgcc.cc: cleaned up warnings. Changed some names to make
725         try to have a uniform coding convention and moved this file into
726         libsupc (see below)
727         * gcc/vtv_memory_pool/vtvmalloc.c: cleaned up and moved to libsupc
728         * gcc/vtv_memory_pool/vtvmalloc.h: fixed LP64 macro name and moved to
729         libsupc
730         * libstdc++-v3/config/abi/pre/gnu.ver: Added vtable map variable pattern
731         to make this symbols extern (available outside the library)
732         Also make the runtime support symbols extern.
733         * libstdc++-v3/libsupc++/Makefile.am: modified to teach the build system
734         about the new files. Special rules to build vtv_init.a library that needs
735         to be linked into each load module.
736         * libstdc++-v3/libsupc++/Makefile.in: this file automatically generated
737         from the Makefile.am by Maketool.
738         * libstdc++-v3/libsupc++/vtv_init.cc: new file. Contains two routines that
739         have init priorities so that they can be executed before and after the
740         init routines that do the calls to RegisterPair.
741         * libstdc++-v3/libsupc++/vtv_malloc.cc: relocated here from gcc directory.
742         Slightly changed named and fixed a few warnings.
743         * libstdc++-v3/libsupc++/vtv_malloc.h: relocated here from gcc directory.
744         Slightly changed named and fixed a few warnings.
745         * libstdc++-v3/libsupc++/vtv_rts.cc: relocated here from gcc directory.
746         previous name was temp-libgcc.c. Fixed some warnings.
747         * vtv_threaded_hash.cc: relocated here from gcc directory.
748         Slightly changed named and fixed a few warnings.
749         * libstdc++-v3/libsupc++/vtv_threaded_hash.h: relocated here from gcc
750         directory. Previous name was temp-libgcc.c. Fixed some warnings.
752 2012-06-08  Caroline Tice  <cmtice@google.com>
754         * gcc/cp/vtable-class-hierarchy.c
755         (vtv_register_class_hierarchy_information): Use num_vtable_map_nodes
756         to decide whether or not to generate vtable verification initialization
757         function.
759 2012-06-07  Caroline Tice  <cmtice@google.com>
761         * gcc/cp/vtv_memory_pool/vtvmalloc.c (obstack_chunk_alloc) Change
762         to use mmap instead of posix_memalign.  Verify page alignment.
764 2012-06-04  Caroline Tice  <cmtice@google.com>
766         * gcc/cp/vtable-class-hierarchy.c (struct list_node, struct node,
767         struct node2): Delete struct definitions.
768         (tree-vtable-verify.h): New include statement.
769         (struct work_node): New struct defintion.
770         (num_classes): New global variable.
771         (vlt_class_hierarchy_info, registered_pairs):  Delete global vars.
772         (linked_list_insert):  Delete function.
773         (binary_tree_insert):  Delete function.
774         (binary_tree_find):  Delete function.
775         (build_transitive_closure):  Delete function.
776         (tree_three_key_insert):  Delete function.
777         (vtable_find_map_decl):  Delete function.
778         (dump_class_hierarchy_information): Remove parameter; completely
779         re-write to use new data structures.
780         (register_all_pairs): Remove first parameter; make non-recursive;
781         modify to iterate through new data structure.  (Main body of code
782         remains the same).  Fix arguments for calls to record_register_pairs
783         and register_vptr_fields.
784         (add_hierarchy_pair):  New function.
785         (add_to_worklist):  New function.
786         (find_and_remove_next_leaf_node):  New function.
787         (record_register_pairs):  Completely rewrite to use new data
788         structures; Remove base_ptr_decl parameter and add base_class
789         parameter.
790         (register_vptr_fields):  Add base_class parameter.  Fix arguments for
791         call to record_register_pairs.
792         (find_graph_node):  New function.
793         (add_edge_to_graph):  New function.
794         (update_class_hierarchy_information):  Remove base_class_ptr_decl
795         parameter. Use new data structures; call add_hierarchy_pair instead
796         of binary_tree_insert.
797         (vtv_register_class_hierarchy_information):  Use new global
798         variable, any_verification_calls_generated, to decide whether or not
799         to register pairs; remove argument from call to
800         dump_class_hierarchy_information; remove vlt_class_hierarchy_info
801         from call to register_all_pairs.
802         (vtable_find_or_create_map_decl):  Modify to use new hash table for
803         accessing *.vtable_map variables; return hash table node rather than
804         var decl.
805         (vtv_save_base_class_info): Modify to use new hash table data
806         structure for vtable_map variables.
807         * gcc/tree-vtable-verify.c: Remove comment from top about code
808         being contributed by Razya Ladelsky (it was accidentally copied in
809         along with the copyright info).
810         (tree-vtable-verify.h):  New include statement.
811         (num_vtable_map_nodes): New global variable.
812         (any_verification_calls_generated):  New global variable.
813         (vtbl_map_node_registration_find): New function.
814         (vtbl_map_node_registration_insert):  New function.
815         (hash_vtable_registration): New function.
816         (eq_vtable_registration):  New function.
817         (vtbl_map_hash): New static global variable.
818         (vtbl_map_nodes): New global variable.
819         (vtbl_map_nodes_array):  New global variable.
820         (vtbl_map_array_insert): New function.
821         (hash_vtbl_map_node):  New function.
822         (eq_vtbl_map_node):  New function.
823         (vtbl_map_get_node):  New function.
824         (vtbl_map_node):  New function.
825         (vtable_var_decl_array):  Delete global variable.
826         (vtable_var_decl_array_max):  Delete global variable.
827         (vtable_var_decl_array_entries):  Delete global variable.
828         (find_vtable_map_decl):  Delete function.
829         (save_vtable_map_decl):  Delete function.
830         (verify_bb_vtables):  Delete unused local variables vtbl_ptr & t;
831         modify to use vtbl_map_hash and hash functions to find/store
832         vtable_map variables; update any_verification_calls_generated; fix
833         formatting (no line longer than 80 chars).
834         (build_vtable_verify_fndecl): Fix line formatting so no line is longer
835         than 80 chars.
836         * gcc/tree-vtable-verify.h: New file.
838 2012-06-04  Caroline Tice  <cmtice@google.com>
840         * gcc/flag-types.h (enum vtv_priority): Add VTV_NO_PRIORITY,
841         to allow the flag to be turned off.
842         * gcc/common.opt (fvtable-verify):  Set the default
843         initialization to VTV_NO_PRIORITY, so the vtable verification
844         is not turned on by default.
846 2012-06-03  Caroline Tice  <cmtice@google.com>
848         * gcc/cp/decl2.c (cp_write_global_declarations):  Change vtable
849         initializaiton priority to MAX_RESERVED_INIT - 1; Add code to
850         put initializer in .preinit_array, if specified by flag.
851         * gcc/flag-tyeps.h (enum vtv_priority):  Add new enum.
852         * gcc/common.opt (fvtable-verify): Modify flag to take an enum
853         argument.  Add the enum information for vtv_priority enums.
854         * gcc/varasm.c (assemble_vtv_preinit_initializer):  New function.
855         * gcc/output.h (assemble_vtv_preinit_initializer): New function decl.
857 2012-06-03  Caroline Tice  <cmtice@google.com>
859         * gcc/config/i386/i386.c (ix86_vtable_security_code_end): Remove
860         function.
861         (ix86_code_end):  Remove call to ix86_vtable_security_code_end.
863 2012-06-03  Caroline Tice  <cmtice@google.com>
865         * gcc/temp-libgcc.cc (__VerifyVtablePointer):  Put hack back in
866         for the moment, to allow various things to build and run, until
867         the more permanent fix is done.
869 2012-06-01  Luis Lozano  <llozano@google.com>
871         * gcc/cgraph.h (debug_varpool_node): add this new routine to be able do
872         dump information about a single node in the varpool.
873         * gcc/varpool.c (debug_varpool_node): add this new routine to be able do
874         dump information about a single node in the varpool.
875         * gcc/config/i386/i386.c (ix86_code_end): disable code to generate
876         fake entry points for the vtable verification runtime library entry points
877         * gcc/cp/vtable-class-hierarchy.c (register_all_pairs): added some debug
878         traces
879         * gcc/temp-libgcc.cc: made some declarations static.
880         (__VerifyVtablePointer): Improved some trace messages
881         * gcc/tree-vtable-verify.c (find_vtable_map_decl): Fixed a couple of
882         compile-time warnings.
883         * libstdc++-v3/config/abi/pre/gnu.ver: added rule so that vtable_map
884         variables are not marked as LOCAL.
886 2012-05-30  Caroline Tice  <cmtice@google.com>
888         * gcc/temp-libgcc.cc (debug_hash): New global variable.
889         (__VerifyVtablePointer):  Removed hack that assumes pointer is
890         valid if data structure is empty. Added call to dump_hashing_statistics
891         on first time through, if flag is set.
892         * gcc/threaded-hash.c:  (num_tables_allocated, num_buckets_created,
893         num_bucket_pointers_allocated, num_slots_filled, num_rehashes,
894         num_rehased_elements, size_of_bucket, size_of_potiner) Added global
895         variables for collecting statistics and profiling information.
896         (bucket_insert): Update num_buckets_created and num_slots_filled.
897         (rehash_elements): Update num_rehashes and num_rehashed_elements.
898         (grow_table): Update num_bucket_poitners_allocated.
899         (vlt_hash_init_table) Update num_tables_allocated and
900         num_bucket_pointers_allocated.
901         (dump_hashing_statistics): New function.
902         * gcc/threaded-hash.h (dump_hashing_statistics): New function decl.
904 2012-05-23  Luis Lozano  <llozano@google.com>
906         * gcc/cp/vtable-class-hierarchy.c: Removed some unneded code for
907         handling of template class instances.
908         (vtable_find_or_create_map_decl): Moved routine from class.c file
909         (vtv_save_base_class_info): Moved routine from class.c file and
910         renamed to be more consistent
911         * gcc/cp/pt.c: removed unnecessary call to record_template_vtable_info
912         * gcc/cp/cp-tree.h: cleaned up prototypes and renamed to all be
913         prefixed by "vtv_"
914         * gcc/cp/decl2.c: Renamed vtable verification function calls according
915         to the changes to cp-tree.h
917 2012-05-21  Caroline Tice  <cmtice@google.com>
919         * gcc/vtv_memory_pool/vtmalloc.c (VTV_malloc_init):  Add code
920         to make sure body of function is never executed more than once.
922 2012-05-21  Caroline Tice  <cmtice@google.com>
924         * gcc/vtv_memory_pool/vtvmalloc.c: Add 'extern "C"'.
925         Reformat function headers to match GCC coding standards.
926         (VTV_protect): Add cast to assignment to ci (to fix G++ compilation
927         error).
928         (VTV_unprotect): Ditto.
929         * gcc/vtv_memory_pool/vtvmalloc.h:  Add 'extern "C"'. Add 'extern'
930         keyword.  Add missing 'void' parameters.
931         * gcc/temp-libgcc.cc: Remove comments from around vtv stuff. Add
932         'extern "C"'.
933         * gcc/threaded-hash.c: Add 'extern "C"'. Remove comments from around
934         vtv stuff.
935         * gcc/threaded-hash.h: Add 'extern "C"'.
937 2012-05-17  Caroline Tice  <cmtice@google.com>
939         * gcc/threaded-hash.c:  New file.
940         * gcc/threaded-hash.h:  New file.
941         * gcc/temp-libgcc.cc:  Modify to include threaded-hash.h; remove all
942         binary tree code; replace binary tree with hash table from
943         threaded-hash.
945 2012-05-16  Luis Lozano  <llozano@google.com>
947         * vtv_memory_pool/vtmalloc.h: New header file for the memory pool for
948         use by the vtable verification. The pool allocates chunks at page
949         boundary so that they can easily be mprotected. This pool also provides
950         the functionality to protect/unprotect the entire pool from writing.
951         * vtv_memory_pool/vtmalloc.c: New Implementation file for the memory
952         pool for the vtable verification.
954 2012-05-15  Caroline Tice  <cmtice@google.com>
956         * gcc/cp/vtable-class-hierarchy.c (struct node2): Rename tree fields,
957         add offset field. 'base_id' became 'base_map_var_decl'; 'vptr_id'
958         became 'vtable_decl'.
959         (tree_two_key_insert):  Renamed function to 'tree_three_key_insert'.
960         Added parameter for third key.  Modified code to insert appropriately
961         for three keys instead of two.
962         (record_register_pairs): Renamed first two parameters, added third
963         parameter.  Calculate offset value. Change call to
964         tree_two_key_insert to a call to tree_three_key_insert, and pass
965         offset as third key.
966         (register_vptr_fields):  Remove code that checks already_registered
967         for ztt_decl. Add already_registered check inside loop. Add
968         val_vtbl_decl and used that for checks and messages instead of
969         vtbl_var_decl.
970         (register_other_binfo_vtables):  Add already_registered check.
971         (register_all_pairs):  Add third argument to call to
972         record_register_pairs.
973         (linked_list_insert):  Modify to check list for class before
974         inserting it; don't insert it if it's already in the list.
976 2012-05-15  Caroline Tice  <cmtice@google.com>
978         * gcc/cp/class.c (vtable_find_or_create_map_decl): Add comments for
979         eventually making vtable map variable sections read-only.
980         * gcc/cp/vtable-class-hierarchy.c (init_functions):  Fix arg_types for
981         both function decls; also add C++-specific characteristics.
982         (tree_two_key_insert):  Fix cut/paste bug (was only traversing right
983         branches; never left).
984         * gcc/temp-libgcc.cc: Remove 'extern "C"'.
985         (__VLTRegisterPair):  Change parameter types to void** and void *. Add
986         code to cast parameters to desired types inside function.  Fix error
987         in format string passed to log_register_pairs.
988         (__VerifyVtablePointer):  Change parameter types to void** and void*.
989         Add code to case parameters to desired types inside function.
990         * gcc/tree-vtable-verify.c (build_vtable_verify_fndecl):  Fix
991         arg_types and add C++-specific characteristics to the function decl.
992         * config/i386/i386.c (ix86_vtable_security_code_end):  Change names
993         for dummy functions to match mangled C++ function names.
995 2012-05-08  Caroline Tice  <cmtice@google.com>
997         * gcc/cp/decl2.c (cp_write_global_declarations):  Check return
998         value of register_class_hierarchy_information; only generate
999         init function if return value is true.
1000         * gcc/cp/vtable-class-hierarchy.c (register_all_pairs):  Add
1001         check to see if binfo has vtable before attempting to call
1002         build_vtbl_address on it.
1004 2012-05-07  Luis Lozano  <llozano@google.com>
1006         * class.c (vtable_find_or_create_map_decl): Added this routine to
1007         find or create the vtable map variable for a record. It checks if
1008         the record contains a vtable (it is interesting from the point of
1009         view of vtable verification) before creating the map variable
1010         (vtable_save_base_class_info): Modified to call the added routine.
1011         Make sure not to add uninteresting records to the hierarchy information.
1013 2012-05-03  Luis Lozano  <llozano@google.com>
1015         * gcc/cp/vtable-class-hierarchy.c (register_vptr_fields): Check if a
1016         VTT is needed and only generate the verification for the refered
1017         conctruction vtables if needed. There seems to be a bug in GCC where
1018         some VTTs are being marked as needed so I also had to check for the
1019         "finalized" flag. This needs to be reviewed.
1021 2012-05-01  Caroline Tice  <cmtice@google.com>
1023         * gcc/cp/decl2.c (cp_write_global_declarations):  Fix size of buffer
1024         array.
1026 2012-04-30  Luis Lozano <llozano@google.com>
1028         * BASE-VER: changed to add "vtable" to version so that we can easily
1029         identify we are using the correct compiler.
1030         * gcc/cp/class.c (vtable_save_base_class_info): added this routine
1031         to walk through BINFO for a record and save into the vtable verification
1032         class hierarchy information. This was based on code previously in the
1033         parser.
1034         * gcc/cp/parser.c (cp_parser_class_specifier_1): removed code to
1035         call update_class_hierarchy_information. This is not a good point to
1036         do this since information about the class (in particular templates)
1037         has not been finalized here.
1038         * gcc/cp/vtable-class-hierarchy.c (dump_class_hierarchy_information):
1039         modified dump to also dump the mangled ids.
1040         (list_append): make sure to compare entries using mangled ids.
1041         (binary_tree_find_template): fixed a memory leak
1042         (build_transitive_closure): fixed a memory leak
1043         (register_vptr_fields): temporarily disable verification of
1044         construction vtables. This is causing undef symbols in the compilation
1045         of omnetpp and soplex.
1046         (register_other_binfo_vtables): make sure this code does not go over
1047         the construction vtables.
1048         * gcc/temp-libgcc.cc: Added code to print stack traces
1050 2012-04-14  Caroline Tice  <cmtice@google.com>
1052         * gcc/cp/decl2.c (cp_write_global_declarations):  Call
1053         compute_class_hierarchy_transitive_closure before calling
1054         cgraph_finalize_compilation_unit.
1055         * gcc/cp/parser.c (cp_parser_class_specifier_1):  Modify
1056         to handle unistantiated templates as base classes (added
1057         the base_is_template code and checks).
1058         * gcc/cp/vtable-class-hierarchy (compute_hierarchy_transitive_closure,
1059         compute_class_hierarchy_transitive_closure): Removed the 'static'
1060         function qualifier and re-named compute_hierarchy_transitive_closure
1061         to compute_class_hierarchy_transitive_closure.
1062         (binary_tree_find_template):  New function, to look up template base
1063         class hierarchies in the vlt_class_hierarchy_info data structure.
1064         (build_transitive_closure):  Add code to deal with an uninstantiated
1065         template class being in the middle of a transitive closure.
1066         (template_list_search):  Use the mangled type name when looking up
1067         template hierarchy data.
1068         (register_all_pairs): Make sure binfo is non-null before calling
1069         BINFO_VTABLE on it.
1070         (record_template_vtable_info): Use the mangled type name when storing
1071         the template hierarchy data.
1072         * gcc/cp/cp-tree.h (compute_class_hierarchy_transitive_closure):
1073         Add extern function decl.
1075 2012-04-13  Caroline Tice  <cmtice@google.com>
1077         Code cleanup and hack removal.
1078         * gcc/cp/vtable-class-hierarchy.c (struct list_node2): Delete struct
1079         definition.
1080         (struct node): Rename field to ptr_decl_or_template_type_id.
1081         (struct node3): Delete struct definition..
1082         (get_class_name): Delete function.
1083         (template_list_insert): Delete function.
1084         (template_info_tree_insert):  Remove vtable_decl parameter.  Modify to
1085         use struct node rather than struct node3.
1086         (template_list_search): Change return type to list_node* instead of
1087         list_node2*.
1088         (template_tree_find): Ditto.  Also change type of first parameter to
1089         node* instead of node3*.  Replace field ptr_decl with
1090         ptr_decl_or_template_type_id.
1091         (vlt_template_vptr_info): Replace struct node3 with struct node.
1092         (register_vptr_fields):  Remove expr_stmt.
1093         (dump_class_hierarchy_information):  Replace references to field
1094         'ptr_decl' with 'ptr_decl_or_template_type_id'.
1095         (binary_tree_find): Ditto.
1096         (build_transitive_closure): Ditto.
1097         (binary_tree_insert): Ditto.
1098         (register_all_pairs): Ditto. Also, remove dead variables expr_stmt and
1099         class_name. Change handling of instantiated template types (add them
1100         to current type list rather than dealing with them separately).  Use
1101         CLASSTYPE_VTABLES to find vtable var decls.
1102         (register_class_hierarchy): Delete dead variable expr_stmt.
1103         (record_template_vtable_info): Remove code to find vtable var decl
1104         here. Don't pass vtable var decl to template_info_tree_insert.
1106 2012-04-12  Caroline Tice <cmtice@google.com>
1108         * gcc/cp/vtable-class-hierarchy.c (register_all_pairs)  Modify
1109         function to traverse entire list of instantiated templates, if
1110         one is found.
1111         * gcc/tree-vtable-verify.c (verify_bb_vtables) Make sure vtbl
1112         is non-NULL before trying to access stuff through it.
1114 2012-04-12  Caroline Tice <cmtice@google.com>
1116         * gcc/gp/decl2.c (cp_write_global_declarations):  Fix conversion
1117         from directory name to function name, replacing '/' and '+' with
1118         underscores.
1119         * gcc/cp/vtable-class-hierarchy.c (register_other_binfo_vtables):
1120         New function (to recursively find offset virtual tables from
1121         multiple inheritance).
1122         (register_all_pairs): Add call to register_other_binfo_vtables.
1124 2012-04-11  Luis Lozano  <llozano@google.com>
1126         * gcc/cp/vtable-class-hierarchy (register_all_pairs): Fixed regression
1127         in handling of virtual bases.
1128         * gcc/temp-libgcc.cc (__VerifyVtablePointer): Added printing of backtrace
1129         on failure. Also printed vtable pointer in case of failed lookup.
1131 2012-04-07  Caroline Tice <cmtice@google.com>
1133         * gcc/cp/init.c (build_vtbl_address):  Remove static function
1134         decl.  Remove 'static' qualifier from function definition.
1135         * gcc/cp/pt.c (instantiate_class_template):  Add call to
1136         record_template_vtable_info, guarded by flag_vtable_verify.
1137         * gcc/cp/decl2.c (start_objects):  Change 'type' from a
1138         static array of chars to a char *.  Add call to xmalloc for it.
1139         Call 'free' for it when done.
1140         (finish_objects):  Check to see if constructor is for vtable
1141         map; if so, store the function decl in vtable_verify_init_fn.
1142         (cp_process_pending_declarations):  Move code that generates
1143         vtable verify constructor function from here to after call to
1144         cgraph_finalize_compilation_unit in cp_write_global_declarations.
1145         Add calls to gimplify_function_tree,
1146         cgraph_add_new_function, and cgraph_process_new_functions.
1147         (cp_write_global_declarations):  Insert code, after call to
1148         cgraph_finalize_compilation_unit, to generate vtable verify
1149         constructor function.  Add calls to gimplify_function_tree,
1150         cgraph_add_new_function, and cgraph_process_new_functions.  Also,
1151         add the last 50 chars of the source directory tree to the name of
1152         the function, to avoid filename conflicts (from files with the
1153         same names in different directories).
1154         * gcc/cp/vtable-class-hierarchy.c (struct list_node2): New type decl.
1155         (tree-iterator.h) New include statement.
1156         (struct node3): New type decl;
1157         (get_class_name): New function.
1158         (template_list_insert): New function.
1159         (template_info_tree_insert): New function.
1160         (template_list_search): New function.
1161         (template_tree_find): New function.
1162         (vlt_template_vptr_info): New data structure.
1163         (init_functions):  Removed commented out code.
1164         (build_transitive_closure): Free var_id_name when done with it.
1165         (register_vptr_fields):  Add new parameter 'body'. Remove calls to
1166         build_stmt and add_stmt.  Call append_to_statement_list to append
1167         the call_expr directly to body.
1168         (register_all_pairs): Add new parameter 'body'.  Remove calls to
1169         build_stmt and add_stmt.  Call append_to_statement_list to append
1170         the call_expr directly to body.  Check to see if class_type is
1171         a template class, and if so, look for the vtable in the template list.
1172         Call build_vtbl_address on the vtable var decl to find the vtable
1173         pointer, rather than try to reconstruct it ourselves.
1174         (register_class_hierarchy_information):  Remove calls to build_stmt
1175         and add_stmt.  Use append_to_statement_list to add call_exprs
1176         directory to body.
1177         (record_template_vtable_info):  New function.
1178         * gcc/cp/cp-tree.h (build_vtbl_address): Add extern function decl.
1179         (record_template_vtable_info): Add extern function decl.
1181 2012-04-01  Caroline Tice <cmtice@google.com>
1183         * gcc/tree.h (save_vtable_map_decl): New extern function decl.
1184         * gcc/cp/Make-lang.in (CXX_AND_OBJCXX_OBJS): Add
1185         vtable-class-hierarchy.o to list of C++ language-specific object
1186         files.
1187         (vtable-class-hierarchy.o): Add rule for building
1188         vtable-class-hierarchy.o
1189         * gcc/cp/decl2.c (start_objects): Add third parameter, for
1190         function name extension.
1191         (generate_ctor_or_dtor_function): Add empty string as third
1192         argument to calls to start_objects.
1193         (cp_process_pending_declarations): Add code to generate special
1194         constructor function with high initialization priority for special
1195         vtable verification calls, if the flag_vtable_verify is set.
1196         * gcc/cp/parser.c (cp_parser_class_specifier_1): If
1197         flag_vtable_verify is set and the current class has base classes,
1198         generate the
1199         *.vtable_map variables for any base classes that don't already
1200         have it and add the base class/derived class pair to the class
1201         hierarchy information.
1202         * gcc/cp/vtable-class-hierarchy.c: New file.
1203         * gcc/cp/mangle.c (get_mangled_id): New function. Copied from PPH
1204         work of Lawrence Crowl and Diego Novillo.
1205         (mangle_decl): Call get_mangled_id rather than doing work directly
1206         here. Copied from PPH work of Lawrence Crowl ande Diego Novillo.
1207         * gcc/cp/cp-tree.h (get_mangled_id): New function decl.
1208         (register_class_hierarchy_information): New function decl.
1209         (update_class_hierarchy_information): New function decl.
1210         (vtable_find_map_decl):  New function decl.
1211         * gcc/temp-libgcc.cc: New file.
1212         * gcc/tree-vtable-verify.cc: (cp/cp-tree.h): New include statement.
1213         (build_vtable_verify_fndecl):  Renamed function (eliminated 's' from
1214         the end).
1215         (my_build1):  New function.
1216         (my_get_vtbl_decl_for_binfo): Renamed function (old name was
1217         get_vtbl_decl_for_binfo).
1218         (vtable_var_decl_array): New global variable.
1219         (vtable_var_decl_array_max): New global variable.
1220         (vtable_var_decl_array_entries): New global variable.
1221         (find_vtable_map_decl): New function.
1222         (save_vtable_map_decl): New function.
1223         (verify_bb_vtables): Fix a few bugs, and add some debugging parameters
1224         for calls to __VerifyVtablePointer.
1225         (build_vtable_verify_fndecl): Remove unnecessary variables.
1226         * gcc/config/i386/i386.c (ix86_vtable_security_code_end):  Modify to
1227         output dummy versions of __VLTChangePermission and __VLTRegisterPair
1228         in addition to __VerifyVtablePointer. Also add code to generate
1229         x86_64 assembly, instead of i386, if it's appropriate.
1231 2012-02-16  Caroline Tice <cmtice@google.com>
1233         * gcc/timevar.def (TV_VTABLE_VERIFICATION): New timevar definition.
1234         * gcc/tree-vtable-verify.c: New file defining vtable verification pass.
1235         * gcc/common.opt (fvtable-verify): New flag, to control vtable
1236         verification pass.
1237         * gcc/Makefile.in (OBJS-common): Add tree-vtable-verify.o to list.
1238         (tree-vtable-verify.o):  Add rule.
1239         * gcc/passes.c (init_optimization_passes):  Add pass_vtable_verify.
1240         * gcc/config/i386/i386.c (ix86_vtable_security_code_end):  New
1241         function to generate weak version of __VerifyVtablePointer.
1242         (ix86_code_end): Add call to ix86_vtable_security_code_end.
1243         * tree-pass.h (pass_vtable_verify): New extern declaration for pass.