[llvm-dev] where does jump table stores?

Robinson, Paul via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 5 18:13:25 PST 2016


> -----Original Message-----
> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of ???
> via llvm-dev
> Sent: Monday, December 28, 2015 10:56 PM
> To: llvm-dev
> Subject: [llvm-dev] where does jump table stores?
> 
> I got the following message from one paper called readactor:
> > We found that the LLVM compiler only emits data in the
> > executable .text section of x86 binaries when optimizing a
> > switch-case statement. LLVM emits the basic block address
> > corresponding to each switch-case in a table after the current
> > function. As shown in the left part of Figure 6, the switch
> > statement is then implemented as a load from this table and
> > an indirect branch to the loaded address.
> 
> I am curious about why llvm puts this jump table(extrances of cases
> for switch). I did the same test for gcc, I found gcc stores it in
> rodata. I think rodata section is a good place for those structures to
> stay.
> If there is any misunderstanding, please inform me.
> Thanks.

I think in PIC mode it used to do this, and from skimming the paper
it looks like they wanted to use ASLR therefore code must be PIC.
I see Rafael made a patch in February to put jump tables in .rodata
consistently, at least for targets using ELF, so that's the behavior
you should see starting probably with LLVM 3.7.
--paulr

> 
> --
> My best regards to you.
> 
>      No System Is Safe!
>      mudongliang
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list