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
Parents
  • Note: This was originally posted on 16th August 2010 at http://forums.arm.com

    I'm not sure I know exactly what you mean by TEXTREL.  I'm guessing it's a non-PC-relative relocation from a .text (or RO) section.  (Such a relocation would have to be performed at load time (by a dynamic linker) for a shared object.)

    Unlike the compiler, the assembler has little or no choice about the relocations it produces.  If you have something like
    ...
    IMPORT foo
    ...
    LDR r0,=foo
    or
    DCD foo
    ...

    then the assembler has to produce a non-PC-relative relocation.

    When you tell armasm '--apcs /fpic' you are promising that it is appropriate to mark the RO sections object code as position-independent.  This is different from building C or C++ code where '--apcs /fpic' is telling the compiler to make sure the RO sections object code are position-independent.

    The assembler can't add the code needed to use a PC-relative relocation, but the compiler can.

    I don't think there's any solution besides finding out what asm constructs are producing the unwanted relocations and changing them.  (Using asm macros might make it easier to maintain.)



    Hi Scott,

       Thank you for the reply.I had removed all the IMPORTS from my assembly but still TEXTREL is coming in library.
    I am building handwritten assembly with armcc only(not sure whether it uses armasm internally).
    My assembly functions are in .c files in following fashion:

    CODE:
    __asm void func1()
    {

    }

    So can you tell me what else may be reason, for generation of TEXTREL in library.

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

    I'm not sure I know exactly what you mean by TEXTREL.  I'm guessing it's a non-PC-relative relocation from a .text (or RO) section.  (Such a relocation would have to be performed at load time (by a dynamic linker) for a shared object.)

    Unlike the compiler, the assembler has little or no choice about the relocations it produces.  If you have something like
    ...
    IMPORT foo
    ...
    LDR r0,=foo
    or
    DCD foo
    ...

    then the assembler has to produce a non-PC-relative relocation.

    When you tell armasm '--apcs /fpic' you are promising that it is appropriate to mark the RO sections object code as position-independent.  This is different from building C or C++ code where '--apcs /fpic' is telling the compiler to make sure the RO sections object code are position-independent.

    The assembler can't add the code needed to use a PC-relative relocation, but the compiler can.

    I don't think there's any solution besides finding out what asm constructs are producing the unwanted relocations and changing them.  (Using asm macros might make it easier to maintain.)



    Hi Scott,

       Thank you for the reply.I had removed all the IMPORTS from my assembly but still TEXTREL is coming in library.
    I am building handwritten assembly with armcc only(not sure whether it uses armasm internally).
    My assembly functions are in .c files in following fashion:

    CODE:
    __asm void func1()
    {

    }

    So can you tell me what else may be reason, for generation of TEXTREL in library.

    Thanks In Advance,
    satish
Children
No data