public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Place jump tables in RELRO only when targets require local relocation to be placed in a read-write section
@ 2022-01-12  7:20 HAO CHEN GUI
  2022-06-01 21:39 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: HAO CHEN GUI @ 2022-01-12  7:20 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool, Bill Schmidt

Hi,
   This patch sets "relocatable" of jump table to true when targets require local relocation to be placed
in a read-write section - bit 0 is set in reloc_rw_mask. Jump tables are in local relocation, so they
should be placed in RELRO only when both global and local relocation need to be placed in a read-write
section. Bit 1 is always set when bit 0 is set.
   Bootstrapped and tested on powerpc64-linux BE/LE and x86 with no regressions. Is this okay for trunk?
Any recommendations? Thanks a lot.

ChangeLog
2022-01-12 Haochen Gui <guihaoc@linux.ibm.com>

gcc/
	* final.c (jumptable_relocatable): Set relocatable to true when
	targets require local relocation to be placed in a read-write section.


patch.diff
diff --git a/gcc/final.c b/gcc/final.c
index 296a9382e91..e86223cb96b 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -2141,7 +2141,7 @@ jumptable_relocatable (void)
   if (!CASE_VECTOR_PC_RELATIVE
       && !targetm.asm_out.generate_pic_addr_diff_vec ()
       && targetm_common.have_named_sections)
-     relocatable = targetm.asm_out.reloc_rw_mask ();
+     relocatable = targetm.asm_out.reloc_rw_mask () == 3;

   return relocatable;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Place jump tables in RELRO only when targets require local relocation to be placed in a read-write section
  2022-01-12  7:20 [PATCH] Place jump tables in RELRO only when targets require local relocation to be placed in a read-write section HAO CHEN GUI
@ 2022-06-01 21:39 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2022-06-01 21:39 UTC (permalink / raw)
  To: gcc-patches



On 1/12/2022 12:20 AM, HAO CHEN GUI via Gcc-patches wrote:
> Hi,
>     This patch sets "relocatable" of jump table to true when targets require local relocation to be placed
> in a read-write section - bit 0 is set in reloc_rw_mask. Jump tables are in local relocation, so they
> should be placed in RELRO only when both global and local relocation need to be placed in a read-write
> section. Bit 1 is always set when bit 0 is set.
>     Bootstrapped and tested on powerpc64-linux BE/LE and x86 with no regressions. Is this okay for trunk?
> Any recommendations? Thanks a lot.
>
> ChangeLog
> 2022-01-12 Haochen Gui <guihaoc@linux.ibm.com>
>
> gcc/
> 	* final.c (jumptable_relocatable): Set relocatable to true when
> 	targets require local relocation to be placed in a read-write section.
It seems unwise to me to rely on the fact that bit1 is already on when 
bit0 is on.    I realize that's likely just preserving existing 
behavior, but unless there's a compelling reason, I'd rather do:

relocatable = (targetm.asm_out.reloc_rw_mask () & 1) != 0;

Which avoids the assumption that if bit0 is on, then bit 1 will always 
be on.
jeff


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-01 21:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12  7:20 [PATCH] Place jump tables in RELRO only when targets require local relocation to be placed in a read-write section HAO CHEN GUI
2022-06-01 21:39 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).