This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PIE/PIC issue ...w.r.t linker variable

On 12/02/16 09:58, Umesh Kalappa wrote:
Hi Kyrill ,
Thank you for the info ,before i file a bug ,need to confirm its a bug or not .

I'm not familiar with linker scripts and the details of -fpie,
so unfortunately I can't judge.

Do file a bug report.
If it is not a bug, it will be closed as such by someone who does
the analysis.


Thank you

On Fri, Feb 12, 2016 at 3:00 PM, Kyrill Tkachov
<> wrote:

On 12/02/16 09:19, Umesh Kalappa wrote:
Hi Guys ,

we  do have a issue with below code ,When we enabled the pie (-fpie/pie)

extern int *my_ptr ;

int main()
     return *my_ptr;

   .syntax unified
   .cpu cortex-m0
   .fpu softvfp
    .global my_ptr
     .global my_var
      .align  2
     .type   my_ptr, %object
     .size   my_ptr, 4
    .word   my_var   //where my_var is the linker variable

custom.ld  (linker script)
/* Set stack top to end of RAM, and stack limit move down by
      190      * size of stack_dummy section */
      191     my_var = 20;
      192     __StackTop = ORIGIN(RAM) + LENGTH(RAM);
      193     __StackLimit = __StackTop - SIZEOF(.stack_dummy);
      194     PROVIDE(__stack = __StackTop);

command used

        3  arm-none-eabi-gcc -c -fPIC main.c -mthumb -mcpu=cortex-m0
        5 arm-none-eabi-gcc -c -fPIC foo.S -mthumb -mcpu=cortex-m0
        6 arm-none-eabi-gcc -c -fPIC

         p_ARMCM0.S -mthumb -mcpu=cortex-m0 -D__STARTUP_CLEAR_BSS
        8 arm-none-eabi-ld -pie main.o  foo.o startup_ARMCM0.o -L.
      m-none-eabi/samples/ldscripts -T nokeep.ld -o test

we expect my_ptr value to be 20 ,but we do see the value 0 and without
pie option ,the my_ptr has the value 20 .

do we missing something here  or value 0 expected (which is incorrect)

note that gcc-bugs is the list where the automatic bug tracker sends all the
logging almost all activity, so your email would be lost there...
Please file a bug report in bugzilla according to


Thank you and appreciate any lights on this

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]