diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-12-03 11:03:30 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-12-03 11:03:30 +0100 |
commit | fe7c3ecff1f9c0520090a77fa824d8c5d9dbec12 (patch) | |
tree | a39e11dcb1a95a13ecbb969e1cef6d4f1f395e4f /gcc/output.h | |
parent | 6262e3a22b3d86afc116480bc59a7bb30b0cfd40 (diff) | |
download | gcc-fe7c3ecff1f9c0520090a77fa824d8c5d9dbec12.zip gcc-fe7c3ecff1f9c0520090a77fa824d8c5d9dbec12.tar.gz gcc-fe7c3ecff1f9c0520090a77fa824d8c5d9dbec12.tar.bz2 |
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 'gcc/output.h')
-rw-r--r-- | gcc/output.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/gcc/output.h b/gcc/output.h index 8f6f153..4a23795 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -470,7 +470,7 @@ struct GTY(()) named_section { /* A callback that writes the assembly code for switching to an unnamed section. The argument provides callback-specific data. */ -typedef void (*unnamed_section_callback) (const void *); +typedef void (*unnamed_section_callback) (const char *); /* Information about a SECTION_UNNAMED section. */ struct GTY(()) unnamed_section { @@ -478,8 +478,8 @@ struct GTY(()) unnamed_section { /* The callback used to switch to the section, and the data that should be passed to the callback. */ - unnamed_section_callback GTY ((skip)) callback; - const void *GTY ((skip)) data; + unnamed_section_callback GTY ((callback)) callback; + const char *data; /* The next entry in the chain of unnamed sections. */ section *next; @@ -503,7 +503,7 @@ struct GTY(()) noswitch_section { struct section_common common; /* The callback used to assemble decls in this section. */ - noswitch_section_callback GTY ((skip)) callback; + noswitch_section_callback GTY ((callback)) callback; }; /* Information about a section, which may be named or unnamed. */ @@ -538,8 +538,8 @@ extern GTY(()) section *bss_noswitch_section; extern GTY(()) section *in_section; extern GTY(()) bool in_cold_section_p; -extern section *get_unnamed_section (unsigned int, void (*) (const void *), - const void *); +extern section *get_unnamed_section (unsigned int, void (*) (const char *), + const char *); extern section *get_section (const char *, unsigned int, tree, bool not_existing = false); extern section *get_named_section (tree, const char *, int); @@ -561,7 +561,7 @@ extern section *get_cdtor_priority_section (int, bool); extern bool unlikely_text_section_p (section *); extern void switch_to_section (section *, tree = nullptr); -extern void output_section_asm_op (const void *); +extern void output_section_asm_op (const char *); extern void record_tm_clone_pair (tree, tree); extern void finish_tm_clone_pairs (void); |