Skip to content

Commit 2ec82e4

Browse files
author
clyon
committed
[ARM/FDPIC v6 08/24] [ARM] FDPIC: Enforce local/global binding for function descriptors
Use local binding rules to decide whether we can use GOTOFFFUNCDESC to compute the function address. 2019-09-10 Christophe Lyon <[email protected]> Mickaël Guêné <[email protected]> gcc/ * config/arm/arm.c (arm_fdpic_local_funcdesc_p): New function. (legitimize_pic_address): Enforce binding rules on function pointers in FDPIC mode. (arm_assemble_integer): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@275570 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 947d905 commit 2ec82e4

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

gcc/ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2019-09-10 Christophe Lyon <[email protected]>
2+
Mickaël Guêné <[email protected]>
3+
4+
* config/arm/arm.c (arm_fdpic_local_funcdesc_p): New function.
5+
(legitimize_pic_address): Enforce binding rules on function
6+
pointers in FDPIC mode.
7+
(arm_assemble_integer): Likewise.
8+
19
2019-09-10 Christophe Lyon <[email protected]>
210
Mickaël Guêné <[email protected]>
311

gcc/config/arm/arm.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,6 +3754,42 @@ arm_options_perform_arch_sanity_checks (void)
37543754
}
37553755
}
37563756

3757+
/* Test whether a local function descriptor is canonical, i.e.,
3758+
whether we can use GOTOFFFUNCDESC to compute the address of the
3759+
function. */
3760+
static bool
3761+
arm_fdpic_local_funcdesc_p (rtx fnx)
3762+
{
3763+
tree fn;
3764+
enum symbol_visibility vis;
3765+
bool ret;
3766+
3767+
if (!TARGET_FDPIC)
3768+
return true;
3769+
3770+
if (! SYMBOL_REF_LOCAL_P (fnx))
3771+
return false;
3772+
3773+
fn = SYMBOL_REF_DECL (fnx);
3774+
3775+
if (! fn)
3776+
return false;
3777+
3778+
vis = DECL_VISIBILITY (fn);
3779+
3780+
if (vis == VISIBILITY_PROTECTED)
3781+
/* Private function descriptors for protected functions are not
3782+
canonical. Temporarily change the visibility to global so that
3783+
we can ensure uniqueness of funcdesc pointers. */
3784+
DECL_VISIBILITY (fn) = VISIBILITY_DEFAULT;
3785+
3786+
ret = default_binds_local_p_1 (fn, flag_pic);
3787+
3788+
DECL_VISIBILITY (fn) = vis;
3789+
3790+
return ret;
3791+
}
3792+
37573793
static void
37583794
arm_add_gc_roots (void)
37593795
{
@@ -7534,7 +7570,9 @@ legitimize_pic_address (rtx orig, machine_mode mode, rtx reg, rtx pic_reg,
75347570
|| (GET_CODE (orig) == SYMBOL_REF
75357571
&& SYMBOL_REF_LOCAL_P (orig)
75367572
&& (SYMBOL_REF_DECL (orig)
7537-
? !DECL_WEAK (SYMBOL_REF_DECL (orig)) : 1)))
7573+
? !DECL_WEAK (SYMBOL_REF_DECL (orig)) : 1)
7574+
&& (!SYMBOL_REF_FUNCTION_P (orig)
7575+
|| arm_fdpic_local_funcdesc_p (orig))))
75387576
&& NEED_GOT_RELOC
75397577
&& arm_pic_data_is_text_relative)
75407578
insn = arm_pic_static_addr (orig, reg);
@@ -23160,7 +23198,9 @@ arm_assemble_integer (rtx x, unsigned int size, int aligned_p)
2316023198
|| (GET_CODE (x) == SYMBOL_REF
2316123199
&& (!SYMBOL_REF_LOCAL_P (x)
2316223200
|| (SYMBOL_REF_DECL (x)
23163-
? DECL_WEAK (SYMBOL_REF_DECL (x)) : 0))))
23201+
? DECL_WEAK (SYMBOL_REF_DECL (x)) : 0)
23202+
|| (SYMBOL_REF_FUNCTION_P (x)
23203+
&& !arm_fdpic_local_funcdesc_p (x)))))
2316423204
{
2316523205
if (TARGET_FDPIC && SYMBOL_REF_FUNCTION_P (x))
2316623206
fputs ("(GOTFUNCDESC)", asm_out_file);

0 commit comments

Comments
 (0)