to make a prom image...
gregory.menke at gsfc.nasa.gov
gregory.menke at gsfc.nasa.gov
Thu Sep 27 13:55:00 UTC 2001
We use objcopy to relocate code, and built a little Python script
shown below to do it. Happily, it works just fine under both Linux
and Cygwin.
========================
#!/usr/bin/python
import sys
import os
try:
try:
fileInput= os.path.abspath( sys.argv[1] )
targetAddr=long(sys.argv[2],16)
fileOutput= os.path.abspath( sys.argv[3] )
except:
print 'locate.py error: ', sys.exc_info()[0]
raise "exit"
if len(sys.argv) != 4:
print 'locate.py incorrect parameters'
raise "exit"
if not os.access(fileInput,os.R_OK):
print 'locate.py unable to read %(fileInput)s' % vars()
raise "exit"
if targetAddr < 0x8000000:
print 'locate.py target address %(targetAddr)08X less than 0x80000000' % vars()
raise "exit"
except "exit":
print
print 'locate.py usage:'
print ' python locate.py <inputFile> <targetAddress> <outputFile>'
print
print ' where: <inputFile> is the pathname of a RTEMS executable'
print ' <targetAddress> is the hex address at which the executable should be located'
print ' <outputFile> is the pathname to receive the located s3 records'
print
sys.exit(0)
print
print ' input file %(fileInput)s' % vars()
print 'output file %(fileOutput)s' % vars()
print 'target address 0x%(targetAddr)08X' % vars()
finfo=os.popen("mips-rtems-objdump -d %(fileInput)s | grep _ftext | cut -b 9-16" % vars(),'r')
baseAddr=long( "0x" + finfo.readline(), 16 )
finfo.close()
print 'execution base address 0x%(baseAddr)08X' % vars()
delta=targetAddr - baseAddr
print 'shifting base address by 0x%(delta)08X' % vars()
os.system("mips-rtems-objcopy --change-addresses 0x%(delta)08X -O srec %(fileInput)s %(fileOutput)s" % vars())
os.chmod(fileOutput,0666)
print 'output file written'
# eof
=========================
This is principally to support our application where we link the app
to run in a particular address range, but store the image w/ a little
relocator routine in a different part of memory. Here, just after the
app is linked, objcopy adds an offset to the addresses so proper S3
records can be generated for burning to eeprom. I suspect warnings
about .data might be ignored, I <guess> its because your software
isn't putting anything in .data. We modified linkcmds to set the base
address where the app will be linked, and to specify memory size,
etc... If you post your linkcmds, I could try commenting on it, but
what I don't know about ld would fill a rather large textbook...
Gregm
> Hello, this sounds like the problem I had with
> m68k-rtems-objcopy. It looks like the silly thing reallocates your
> code... Can anybody shead any light on this? It realy is
> unhandy... I posted somthing under the subject "ObjCopy" and did
> not get any response. Looks like I am the only one using ObjCopy...
> Thanks for any comments and help that will be given! Gerke
>
> *********** REPLY SEPARATOR ***********
>
> On 27/09/01 at 11:38 Stan wrote:
> Hello,
>
> I try to make a prom image;
>
> can you help me ?
>
>
> after make,
>
> m68k-rtems-size : text=47984 data=2208 bss=14512 dec=64704 hex=fcc0
>
> and,
>
> m68k-rtems-objcopy: warning :
> --change-section-vma .data = 0x00000000 never used
>
> m68k-rtems-objcopy: warning :
> --change-section-lma .data = 0x00000000 never used
>
>
> Can you tell me if linkcmd and hello.num are good ?
>
> Thank's.
More information about the users
mailing list