This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Power 64 ELFv2 w.r.t toc(cmodel=medium) on windows.
On Fri, Oct 26, 2018 at 10:27 AM Umesh Kalappa <umesh.kalappa0@gmail.com> wrote:
>
> Thank you David for the information.
> >>Are you asking about semantics or syntax? Which source code do you
> not want to change?
> My bad was not clear in the first go and the questions was why on PE
> format the relocation is R_PPC64_TOC16 is generated for global access
> and on ELF why its R_PPC64_TOC16_HA and R_PPC64_TOC16_LO is generated
> for same global access ? why this difference ?
Relocations are specific to ABIs. In the medium code model, the ELF
ABI allows a 32 bit offset relative to the TOC (high and low parts).
AIX does not support medium code model of 32 bit data offset from TOC,
it only provides the larger TOC offset inserted by the linker.
There is no support in the rs6000 backend for PE file format and ABI.
Your "Windows" build is adopting whatever configuration bits fall out
when ELF and AIX are not specified.
>
> then irrespective of object file formats ,the RELOCATION should be
> same for the given target,right ?
No. Relocations are specific to each ABI.
>
> for more info
> we are using bintuills (2.29) and we run the assembler like
> $as.exe -v -a64 -me6500 -many -mbig -o test.o test.s
>
> lets compiler(gcc) emit the syntax as PE format ,but we need
> assembler emit relocations like ELF for mcmodel=medium /large .,is
> that possible .
>
> or like you suggested change the compiler to emit the ELF syntax for
> global access ?
I don't know about Windows and PE. I doubt that adjusting GCC to
behave more like ELF or more like AIX will magically fix your Windows
PE configuration.
I have no idea where you obtained the toolchain and what "ccpc" means.
If it's your toolchain, you need to debug it and add the appropriate
PE support. If you received it from a vendor, you need to ask the
vendor.
Thanks, DAvid
>
> Thank you again
> ~Umesh
>
>
> On Fri, Oct 26, 2018 at 6:57 PM David Edelsohn <dje.gcc@gmail.com> wrote:
> >
> > On Thu, Oct 25, 2018 at 11:53 AM Umesh Kalappa <umesh.kalappa0@gmail.com> wrote:
> > >
> > > Hi All,
> > >
> > > For the below code (test.c)
> > >
> > > int foo()
> > > {
> > > printf("Hello World");
> > > }
> > >
> > > On linux :
> > > ccpc -mcpu=e6500 -mno-altivec -mabi=no-altivec -D_WRS_HARDWARE_FP
> > > -mabi=elfv2 -mcmodel=med -mhard-float -S test.c
> > >
> > > linux asm :
> > > the constant string fetched like
> > >
> > > addis 3,2,.LC0@toc@ha
> > > addi 3,3,.LC0@toc@l
> > >
> > > where offset signed 32 bit used relatively to toc base on linux as
> > > expected for the medium code model .
> > > and the relocation entry will be generated by gas :
> > > R_PPC64_TOC16_HA and R_PPC64_TOC16_LO
> > >
> > > For Windows :
> > >
> > > same command and windows asm looks like
> > >
> > > la 3,.LC0@toc(2)
> > >
> > > where offset used signed 16 bit used relatively to toc base why it so ?.
> > > and the relocation entry will be :
> > > R_PPC64_TOC16 (signed 16 bit offset )
> > >
> > > why this difference and when we greping the .md file and we found
> > > patterns (rs6000.md ) like
> > >
> > > ;; Largetoc support
> > > (define_insn "*largetoc_high"
> > > [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
> > > (high:DI
> > > (unspec [(match_operand:DI 1 "" "")
> > > (match_operand:DI 2 "gpc_reg_operand" "b")]
> > > UNSPEC_TOCREL)))]
> > > "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
> > > "addis %0,%2,%1@toc@ha")
> > >
> > > (define_insn "*largetoc_high_aix<mode>"
> > > [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
> > > (high:P
> > > (unspec [(match_operand:P 1 "" "")
> > > (match_operand:P 2 "gpc_reg_operand" "b")]
> > > UNSPEC_TOCREL)))]
> > > "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
> > > "addis %0,%1@u(%2)")
> > >
> > > the above patterns answered the difference b/w windows and linux .
> > >
> > > Questions to the expert is that using the medium code model ,how we
> > > can get the same linux semantics on windows (without source code
> > > changes) ?
> > >
> > > or above distinguish patterns for a reason and which we are missing here ?
> >
> > Linux uses the ELF file format and assembler syntax. AIX uses the AIX
> > file format and assembler syntax.
> >
> > Windows uses PE file format and syntax, which is not supported in the
> > rs6000 or powerpcspe ports.
> >
> > Are you asking about semantics or syntax? Which source code do you
> > not want to change? If you want to target PE assembler, GCC needs to
> > be taught about that syntax, or at least it needs to generate the ELF
> > syntax for Windows PE.
> >
> > Thanks, David