This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem in generating position independent code with out TEXTREL

Note: This was originally posted on 12th August 2010 at http://forums.arm.com

Hi Experts,

Issue:Not able to remove TEXTREL from our static library generated with --apcs /fpic option using armcc(RVCT 4.0 build 771  tool chain)

Description:
    We compiled our codebase(some modules with handwritten assembly) using armcc(RVCT 4.0 build 771  tool chain) to get static libraries, and then these are used by gstreamer module which further compiles using the above generated libraries with wrappers using GCC tool chain and creates shared objects(.so).

Even though we use equivalent --apcs /fpic compile time option during static library creation to remove position independent code, the TEXTREL are not going from library.
When we disable the (handwritten assembly) in the above mentioned codebase, TEXTRELs go away.
As there are lot of handwritten ARM assembly functions,its difficult to enable one by one and compile and check. :unsure:

So,Experts please throw some light on this issue.


Thanks In Advance,
satish
  • Note: This was originally posted on 6th September 2010 at http://forums.arm.com

    If we are specifying "--apcs /fpic" for compiling c/c++ code that has ARM inline assembly, Can we use r9 register as normal register?  Section 6.3 of APCS, says for rwpi , r9 cannot be used as normal register.  Can you clarify compiler behaviour for  --apcs /fpic and rwpi ?

    /fpic is for creating SysV-style shared libraries (e.g. for use under Linux).  If you're using /fpic then r9 is a normal callee-saved register.

    /rwpi is a different approach to shared libraries that may be used by some other OSes. If you're using /rwpi then you have to make sure r9 is correctly setup (for example by not changing it) when you call a function and when you return -- this is what section 6.3 of aapcs is about.  But, if you are a leaf function, then you can treat r9 as a normal callee-saved register.
  • Note: This was originally posted on 3rd January 2011 at http://forums.arm.com

    Hi Experts,


        I was able te resolve the TEXTREL issues(by avoiding functions calls using LDR and DCD/DCW...for data) in some code bases with the solutions provided by Scott & others............
    Now i am working on some other code base where i am facing TEXTREL issues due to access of tables.
    Please go through the below mentioned sample program which replicates my issues.........

    short int table[30] = {1,2,3,4,5,.......,30};

    void foo {
      
          ...
            LDR r0,=foo
    or
            DCD foo
            ...
    }