public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Gary Thomas <gary@mlbassoc.com>
To: "Øyvind Harboe" <oyvind.harboe@zylin.com>
Cc: eCos Discussion <ecos-discuss@sources.redhat.com>
Subject: Re: [ECOS] __attribute aligned and objcopy
Date: Thu, 25 Sep 2003 10:59:00 -0000	[thread overview]
Message-ID: <1064487578.1015.2645.camel@hermes> (raw)
In-Reply-To: <004001c38351$080aa1d0$73dea8c0@lair>

[-- Attachment #1: Type: text/plain, Size: 1784 bytes --]

On Thu, 2003-09-25 at 04:37, Øyvind Harboe wrote:
> This is driving me nuts, and I can't seem to find a solution
> to this on the net.
> 
> I have a romfs image that I try to convert to a .o file using:
> 
> 
> # how do I add a __attribute((aligned(4))__ to objcopy?
> 
> arm-elf-objcopy -B arm -I binary -O elf32-littlearm --rename-section
> .data=.rodata1 $*.rawdata $(OUTPUT)/$*_raw.o
> 
> This is used to mount a ROMFS:
> 
> extern "C"
> {
> extern const cyg_uint8  _binary___rom_rawdata_start[];
> }
> 
> // this is not aligned to 4 bytes, and hence it does not work
> sprintf( address, "%p", _binary___rom_rawdata_start);
> err = mount( address, "rom", "romfs" );
> 	

What I've done in the past is use GCC to get the magic right.  Try 
looking at packages/hal/arm/edb7xxx/current/misc/long*.h
These are binary data files which I then pass through GCC.

I generated them using 'hexdump'.  You can write a script to produce
most any output you'd like.  I've attached the few that I use.  To
use the script:
  % hexdump -f hex_init FILE
  0x23, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, // 0x000008
  0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, // 0x000010
  0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, // 0x000018
  0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, // 0x000020
  0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, // 0x000028
  0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, // 0x000030
Be sure and use the "-v" option, or else it can end up like this:
  0x23, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, // 0x000008
  0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, // 0x000010
  *
  0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x0a, 0x23, // 0x000050
  0x0a, 0x23, 0x20, 0x20, 0x20, 0x20, 0x65, 0x63, // 0x000058

-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates

[-- Attachment #2: hex_fx --]
[-- Type: text/plain, Size: 46 bytes --]

"0x%06.6_ax "  16/1 "%02x "
"  |" "%_p"
"|\n"

[-- Attachment #3: hex_fx2 --]
[-- Type: text/plain, Size: 41 bytes --]

"/* 0x%06.6_ax */ "  16/1 "0x%02x,"
"\n"

[-- Attachment #4: hex_init --]
[-- Type: text/plain, Size: 35 bytes --]

8/1 "0x%02x, " " // 0x%06.6_ax\n"


[-- Attachment #5: Type: text/plain, Size: 146 bytes --]

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

  reply	other threads:[~2003-09-25 10:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-25 10:37 Øyvind Harboe
2003-09-25 10:59 ` Gary Thomas [this message]
2003-09-25 13:51   ` Øyvind Harboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1064487578.1015.2645.camel@hermes \
    --to=gary@mlbassoc.com \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=oyvind.harboe@zylin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).