aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-12-03 11:03:30 +0100
committerJakub Jelinek <jakub@redhat.com>2021-12-03 11:03:30 +0100
commitfe7c3ecff1f9c0520090a77fa824d8c5d9dbec12 (patch)
treea39e11dcb1a95a13ecbb969e1cef6d4f1f395e4f /libcpp
parent6262e3a22b3d86afc116480bc59a7bb30b0cfd40 (diff)
pch: Add support for PCH for relocatable executables [PR71934]
So, if we want to make PCH work for PIEs, I'd say we can: 1) add a new GTY option, say callback, which would act like skip for non-PCH and for PCH would make us skip it but remember for address bias translation 2) drop the skip for tree_translation_unit_decl::language 3) change get_unnamed_section to have const char * as last argument instead of const void *, change unnamed_section::data also to const char * and update everything related to that 4) maybe add a host hook whether it is ok to support binaries changing addresses (the only thing I'm worried is if some host that uses function descriptors allocates them dynamically instead of having them somewhere in the executable) 5) maybe add a gengtype warning if it sees in GTY tracked structure a function pointer without that new callback option Here is 1), 2), 3) implemented. Note, on stdc++.h.gch/O2g.gch there are just those 10 relocations without the second patch, with it a few more, but nothing huge. And for non-PIEs there isn't really any extra work on the load side except freading two scalar values and fseek. 2021-12-03 Jakub Jelinek <jakub@redhat.com> PR pch/71934 gcc/ * ggc.h (gt_pch_note_callback): Declare. * gengtype.h (enum typekind): Add TYPE_CALLBACK. (callback_type): Declare. * gengtype.c (dbgprint_count_type_at): Handle TYPE_CALLBACK. (callback_type): New variable. (process_gc_options): Add CALLBACK argument, handle callback option. (set_gc_used_type): Adjust process_gc_options caller, if callback, set type to &callback_type. (output_mangled_typename): Handle TYPE_CALLBACK. (walk_type): Likewise. Handle callback option. (write_types_process_field): Handle TYPE_CALLBACK. (write_types_local_user_process_field): Likewise. (write_types_local_process_field): Likewise. (write_root): Likewise. (dump_typekind): Likewise. (dump_type): Likewise. * gengtype-state.c (type_lineloc): Handle TYPE_CALLBACK. (state_writer::write_state_callback_type): New method. (state_writer::write_state_type): Handle TYPE_CALLBACK. (read_state_callback_type): New function. (read_state_type): Handle TYPE_CALLBACK. * ggc-common.c (callback_vec): New variable. (gt_pch_note_callback): New function. (gt_pch_save): Stream out gt_pch_save function address and relocation table. (gt_pch_restore): Stream in saved gt_pch_save function address and relocation table and apply relocations if needed. * doc/gty.texi (callback): Document new GTY option. * varasm.c (get_unnamed_section): Change callback argument's type and last argument's type from const void * to const char *. (output_section_asm_op): Change argument's type from const void * to const char *, remove unnecessary cast. * tree-core.h (struct tree_translation_unit_decl): Drop GTY((skip)) from language member. * output.h (unnamed_section_callback): Change argument type from const void * to const char *. (struct unnamed_section): Use GTY((callback)) instead of GTY((skip)) for callback member. Change data member type from const void * to const char *. (struct noswitch_section): Use GTY((callback)) instead of GTY((skip)) for callback member. (get_unnamed_section): Change callback argument's type and last argument's type from const void * to const char *. (output_section_asm_op): Change argument's type from const void * to const char *. * config/avr/avr.c (avr_output_progmem_section_asm_op): Likewise. Remove unneeded cast. * config/darwin.c (output_objc_section_asm_op): Change argument's type from const void * to const char *. * config/pa/pa.c (som_output_text_section_asm_op): Likewise. (som_output_comdat_data_section_asm_op): Likewise. * config/rs6000/rs6000.c (rs6000_elf_output_toc_section_asm_op): Likewise. (rs6000_xcoff_output_readonly_section_asm_op): Likewise. Instead of dereferencing directive hardcode variable names and decide based on whether directive is NULL or not. (rs6000_xcoff_output_readwrite_section_asm_op): Change argument's type from const void * to const char *. (rs6000_xcoff_output_tls_section_asm_op): Likewise. Instead of dereferencing directive hardcode variable names and decide based on whether directive is NULL or not. (rs6000_xcoff_output_toc_section_asm_op): Change argument's type from const void * to const char *. (rs6000_xcoff_asm_init_sections): Adjust get_unnamed_section callers. gcc/c-family/ * c-pch.c (struct c_pch_validity): Remove pch_init member. (pch_init): Don't initialize v.pch_init. (c_common_valid_pch): Don't warn and punt if .text addresses change. libcpp/ * include/line-map.h (class line_maps): Add GTY((callback)) to reallocator and round_alloc_size members.
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/include/line-map.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 8b5e2f82982..bc40e333579 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -803,11 +803,11 @@ public:
unsigned int max_column_hint;
/* The allocator to use when resizing 'maps', defaults to xrealloc. */
- line_map_realloc reallocator;
+ line_map_realloc GTY((callback)) reallocator;
/* The allocators' function used to know the actual size it
allocated, for a certain allocation size requested. */
- line_map_round_alloc_size_func round_alloc_size;
+ line_map_round_alloc_size_func GTY((callback)) round_alloc_size;
struct location_adhoc_data_map location_adhoc_data_map;