linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* (Manually) relocate PPC code?
@ 2000-07-01 18:39 Wolfgang Denk
  2000-07-01 22:25 ` Daniel Jacobowitz
  2000-07-03  9:45 ` Gabriel Paubert
  0 siblings, 2 replies; 3+ messages in thread
From: Wolfgang Denk @ 2000-07-01 18:39 UTC (permalink / raw)
  To: linuxppc-dev


Hi,

I need to write some C code on PPC which must stay relocatable, resp.
I must relocate it myself (all of code and data etc.). I'm using GNU
tools.

This is for a standalone application, _NOT_ running under Linux.

Where can I find documentation about things like the format of the
GOT etc., or ideally existing _simple_ (read: small) example code?

All hints, pointers, ideas appreciated - TIA!

Wolfgang

--
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd@denx.de
Little known fact about Middle Earth:   The Hobbits had a very sophi-
sticated computer network!   It was a Tolkien Ring...

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: (Manually) relocate PPC code?
  2000-07-01 18:39 (Manually) relocate PPC code? Wolfgang Denk
@ 2000-07-01 22:25 ` Daniel Jacobowitz
  2000-07-03  9:45 ` Gabriel Paubert
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2000-07-01 22:25 UTC (permalink / raw)
  To: linuxppc-dev


On Sat, Jul 01, 2000 at 08:39:14PM +0200, Wolfgang Denk wrote:
>
> Hi,
>
> I need to write some C code on PPC which must stay relocatable, resp.
> I must relocate it myself (all of code and data etc.). I'm using GNU
> tools.
>
> This is for a standalone application, _NOT_ running under Linux.
>
> Where can I find documentation about things like the format of the
> GOT etc., or ideally existing _simple_ (read: small) example code?
>
> All hints, pointers, ideas appreciated - TIA!

It's not terribly small, but - you REALLY should read ld.so.1's source.
There may be more information in the ABI document floating around, too.

Dan

/--------------------------------\  /--------------------------------\
|       Daniel Jacobowitz        |__|        SCS Class of 2002       |
|   Debian GNU/Linux Developer    __    Carnegie Mellon University   |
|         dan@debian.org         |  |       dmj+@andrew.cmu.edu      |
\--------------------------------/  \--------------------------------/

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: (Manually) relocate PPC code?
  2000-07-01 18:39 (Manually) relocate PPC code? Wolfgang Denk
  2000-07-01 22:25 ` Daniel Jacobowitz
@ 2000-07-03  9:45 ` Gabriel Paubert
  1 sibling, 0 replies; 3+ messages in thread
From: Gabriel Paubert @ 2000-07-03  9:45 UTC (permalink / raw)
  To: Wolfgang Denk; +Cc: linuxppc-dev


On Sat, 1 Jul 2000, Wolfgang Denk wrote:

>
> Hi,
>
> I need to write some C code on PPC which must stay relocatable, resp.
> I must relocate it myself (all of code and data etc.). I'm using GNU
> tools.

Do you know about the -mrelocatable gcc and gas option ? Granted that it
generates slightly larger code, but it helps a lot to solve this kind of
problems.

> This is for a standalone application, _NOT_ running under Linux.

Fine.

> Where can I find documentation about things like the format of the
> GOT etc., or ideally existing _simple_ (read: small) example code?

Well, prepboot does this (with many more things): download a pristine
2.2.12 and apply the mvme2600 patches that you'll find at
ftp://vlab1.iram.es/pub/linux-2.2/. You'll then find a medium size example
in arch/ppc/prepboot. Actually it could be used to load a standalone
program or be integrated with it (except that you'll have to modify the
Makefile and the linker script which imports a couple of kernel symbols).

Actually prepboot may even be more complex than what you need since it
first relocates itself whereever it happens to be loaded by firmware and
then analyzes the memory map and setup of the machine before moving itself
and relocating again. The part between both relocations is easy to break
(there are many things you can't do like accessing the bss since it may
extend past the end of memory or whatever, and you can't easily use
pointers since they would not be relocated properly in the second pass),
but once the final relocation is done, the environment is reasonably
friendly (don't expect a full libc either but console I/O and a simple
memory management layer are available).

No interrupts however, this is left as an exercise for the reader. The MMU
exception handlers can be used as a starting point (especially the only
part which must be written in assembler for entry and exit).

> All hints, pointers, ideas appreciated - TIA!

Hope this helps....

	Gabriel.


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-07-03  9:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-07-01 18:39 (Manually) relocate PPC code? Wolfgang Denk
2000-07-01 22:25 ` Daniel Jacobowitz
2000-07-03  9:45 ` Gabriel Paubert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).