Hi! On Mon, Aug 17, 2020 at 10:28:31AM +0800, HAO CHEN GUI wrote: > >For the reloc, my understanding is the jump table needs to be > >relocated if it's a non-relative jump table and PIC flag is set at the > >same time.
Yes, I did say the *existing* code seems sub-optimal, too :-) > >According to the slice of code in stmt.c, the non-relative jump table > >is created with PIC flag set when CASE_VECTOR_PC_RELATIVE is false, > >flag_pic is true and targetm.asm_out.generate_pic_addr_diff_vec is > >false. So I set the reloc to > > > >reloc = (! CASE_VECTOR_PC_RELATIVE && flag_pic && > > ! targetm.asm_out.generate_pic_addr_diff_vec ()) ? 1 > >: 0; > > > >The funcation_rodata_section is not only for jump tables. It's no > >relro in other cases. I am not sure if it's suitable to put selecting > >relro section in it. Of course, I can create a separate function for > >section selection of jump table and send its output to > >funcation_rodata_section. .data.rel.ro is just another kind of .rodata, one that *can* be relocated. So when we use it, fPIC or not doesn't matter. Also, we can just use the existing rodata functions for generating .data.rel.ro, and it should simplify all code even. > -@deftypefn {Target Hook} {section *} TARGET_ASM_FUNCTION_RODATA_SECTION > (tree @var{decl}) > -Return the readonly data section associated with > +@deftypefn {Target Hook} {section *} TARGET_ASM_FUNCTION_RODATA_SECTION > (tree @var{decl}, bool @var{section_reloc}) > +Return the readonly or reloc readonly data section associated with Should this take the 2-bit int "reloc" field like other functions, instead of this bool? Segher