RE: Trying to build position independent code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Trying to build position independent code



Hi,

Sorry for the confusion. The Position independent code works well with
other compiler but not Code Sourcery GNU. The issue is still open.

Tom
-----Original Message-----
From: Robinson, Jeremy 
Sent: Wednesday, October 03, 2007 8:45 PM
To: arm-gnu@xxxxxxxxxxxxxxxx
Cc: Sumardi, Thomas; Whatley, Bryan; Manning, Mike
Subject: RE: Trying to build position independent code

Thomas has just informed me that he has found a way to make it work.

Still, we may need to contact you again for help with your tools in the
future.  Is there a better contact we should use for support?

Thank you,
Jeremy Robinson 

-----Original Message-----
From: Robinson, Jeremy
Sent: Wednesday, October 03, 2007 3:11 PM
To: 'arm-gnu@xxxxxxxxxxxxxxxx'
Cc: Sumardi, Thomas; Whatley, Bryan; Manning, Mike
Subject: Trying to build position independent code

I am an engineer from Mentor Graphics, formerly Accelerated Technology,
trying to port our Nucleus C++ BASE product as position-independent code
so it can work with our Nucleus Dynamic Download product.  The Nucleus
C++ BASE product works great using CS ARM GNU tools, and our Nucleus
Dynamic Download product also works well.  However, when you try and use
the 2 products together, there is a problem.  This combination has been
proven to work using other toolsets, but when building for CS ARM GNU
tools, we have determined that virtual methods in a class are not being
built as position independent, even though -fPIC is used on the compiler
line.

To give a more elaborate example, we can build and run our application
loader executable.  While it is running, we use it's application
interface to download a position-independent C++ application into it.
The startup code for the C++ application runs fine.  It creates a task,
and the code within that task also starts to execute.  All of the
addresses have been remapped successfully so far, and we can even make
calls into the libraries that live inside the application loader.  Then
we come to our first C++ class.  The constructor is called and executes
fine.  Another class method is also called successfully.  Then we try
and call a public virtual method of the same class.  Boom.  Upon
investigating the registers when the application tries to call that
virtual method, the application tries to branch to an address that has
not been offset by the application module load address.  If we manually
change the value of the register at run-time in the debugger, only then
will it successfully call the virtual method.

All of our code for the position-independent application module is
compiled using the -fPIC switch.  We have seen that the linker has a
--pic-executable switch, but our application doesn't work nearly as well
when that is used.  We are however using the --srec-forceS3 switch when
using arm-none-eabi-objcopy to create the srecord.  We have not found
any specific tool information that tells us exactly how these switches
should be used.

We are using the following version of the tool:
gcc version 3.4.2 (release) (CodeSourcery ARM Q3D 2004)

We are under pressure to solve this problem for a customer that wants to
use this combination.

Is there any known issue with virtual methods when using -fPIC?

Also, please supply us with any information regarding how to build
position-independent code using CS ARM GNU tools.

Thank you,
Jeremy Robinson