Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #584 > unrolled thread

AIF header - how?

Started byBob Latham <bob@sick-of-spam.invalid>
First post2011-08-11 12:11 +0100
Last post2011-08-13 10:42 +0100
Articles 11 — 7 participants

Back to article view | Back to comp.sys.acorn.programmer


Contents

  AIF header - how? Bob Latham <bob@sick-of-spam.invalid> - 2011-08-11 12:11 +0100
    Re: AIF header - how? Martin Bazley <martin.bazley@blueyonder.co.uk> - 2011-08-11 16:43 +0100
      Re: AIF header - how? Bob Latham <bob@sick-of-spam.invalid> - 2011-08-11 17:21 +0100
        Re: AIF header - how? cferris@freeRemoveuk.com.invalid - 2011-08-11 20:11 +0100
          Re: AIF header - how? Bob Latham <bob@sick-of-spam.invalid> - 2011-08-11 21:19 +0100
            Re: AIF header - how? John Tytgat <this@is.invalid> - 2011-08-12 12:58 +0200
              Re: AIF header - how? cferris@freeRemoveuk.com.invalid - 2011-08-12 13:11 +0100
                Re: AIF header - how? druck <news@druck.org.uk> - 2011-08-13 15:09 +0100
          Re: AIF header - how? jgharston <jgh@arcade.demon.co.uk> - 2011-08-11 15:49 -0700
    Re: AIF header - how? Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-08-13 00:57 +0200
    Re: AIF header - how? Bob Latham <bob@sick-of-spam.invalid> - 2011-08-13 10:42 +0100

#584 — AIF header - how?

FromBob Latham <bob@sick-of-spam.invalid>
Date2011-08-11 12:11 +0100
SubjectAIF header - how?
Message-ID<52010da5d2bob@sick-of-spam.invalid>
Hi,

I've just found out that none of the programs I've ever written will run
on OS6.20. They all give an error message "The application uses an
obsolete executable file format which is no longer supported by RISC OS".

After a large amount of googling it seems I need to provide an AIF header.

I've looked at page 4-436 in my OS 3 PRMs and it seems to suggest I should
be linking AOF files. This means nothing to me what_so_ever.

Would some kind person explain if I can provide such a thing using the
Basic assembler which I use and point me at something a bit more
understandable than the PRMs if possible.

Sorry, if I sound unhappy, but I am. Being able to knock up a bit of code
and run it is a major reason why I've stayed with RISC OS. If someone just
decides to wipe that out even though RO is struggling for users and is
having to change progs for 32bit and beagle etc. I'm speechless. Very
microsoft - we'll control what you do/run on your machine, we know better
than you.

Thanks 

Bob.

[toc] | [next] | [standalone]


#585

FromMartin Bazley <martin.bazley@blueyonder.co.uk>
Date2011-08-11 16:43 +0100
Message-ID<8b8f260152.martin@blueyonder.co.uk>
In reply to#584
The following bytes were arranged on 11 Aug 2011 by Bob Latham :

> Hi,
>
> I've just found out that none of the programs I've ever written will run
> on OS6.20. They all give an error message "The application uses an
> obsolete executable file format which is no longer supported by RISC OS".
>
> After a large amount of googling it seems I need to provide an AIF header.

An AIF header is what files of type Absolute (&FF8) typically start
with.  I don't know specifics, but I do know that it's of a fixed size,
and that the first 16 bytes (4 words) are all either branch commands to
various areas of the program which are defined to do certain tasks, or
"MOV R0,R0" if not applicable to this program.  The first instruction
jumps to decompression code, if the executable is compressed, and I
think the fourth jumps to the program proper.  The fifth word is always
the instruction "SWI OS_Exit".

AIF headers are generated automatically by all C compilers, with the
exception of recent versions of GCC which enforce a Unix format called
ELF instead, so if your program didn't work then it wasn't written in C.

There's no practical reason why a program shouldn't run without an AIF
header, but ROL in their infinite wisdom have decided suddenly to
enforce a whole lot of standards for no particular reason at all,
including some (like the Utility header) which didn't even exist before
they enforced them.  The reason invariably given is 32-bit
compatibility, and the capability to automatically patch old software to
run on new machines, which is a bit rich given that none of ROL's modern
products run on a 32-bit machine and Acorn's patch mechanism has never
once been used in its 15-year history.

The underlying problem is the same as the one which infamously caused
ROL OSes to start refusing to run binaries compressed using modern
versions of the Squeeze tool - the notorious "Unable to start
application (decompression failed)" error, in spite of the fact that
there was nothing actually wrong with the binaries.

However, unlike the decompression problem, ROL *have* built in a
workaround for the AIF problem.  In Configure, there's a section called
"Compatibility", in which every single option button should be ticked.
If you do this, Configure will warn you that you are potentially
jeopardising your computer by running unstable software.  Ignore it,
it's lying - unless you consider your software, and a lot of other
long-used programs, to be unstable.

-- 
  __<^>__   Red sky in the morning: Shepherd's warning
 / _   _ \  Red sky at night: Shepherd's delight
( ( |_| ) ) Mince and potatoes: Shepherd's pie
 \_>   <_/  ======================= Martin Bazley ==========================

[toc] | [prev] | [next] | [standalone]


#586

FromBob Latham <bob@sick-of-spam.invalid>
Date2011-08-11 17:21 +0100
Message-ID<52012a031abob@sick-of-spam.invalid>
In reply to#585
In article <8b8f260152.martin@blueyonder.co.uk>,
   Martin Bazley <martin.bazley@blueyonder.co.uk> wrote:

> However, unlike the decompression problem, ROL *have* built in a
> workaround for the AIF problem.  In Configure, there's a section called
> "Compatibility", in which every single option button should be ticked.
> If you do this, Configure will warn you that you are potentially
> jeopardising your computer by running unstable software.  Ignore it,
> it's lying - unless you consider your software, and a lot of other
> long-used programs, to be unstable.

Martin, Thank you so much for that. A big relief.

I had sent an application of mine to someone who uses 6.20 and to my
embarrassment he then informs me that it doesn't run. He new nothing of
the reason and neither did I.

Hopefully things aren't as grim as I first feared and a config change will
fix things.

Thanks again.

Cheers,

Bob.

-- 
Bob Latham
Stourbridge, West Midlands

[toc] | [prev] | [next] | [standalone]


#587

Fromcferris@freeRemoveuk.com.invalid
Date2011-08-11 20:11 +0100
Message-ID<ca8b390152.cferris@cferris.freeuk.com>
In reply to#586
In message <52012a031abob@sick-of-spam.invalid>
          Bob Latham <bob@sick-of-spam.invalid> wrote:

> In article <8b8f260152.martin@blueyonder.co.uk>,
>    Martin Bazley <martin.bazley@blueyonder.co.uk> wrote:
[snip]

> I had sent an application of mine to someone who uses 6.20 and to my
> embarrassment he then informs me that it doesn't run. He new nothing of
> the reason and neither did I.
>
[snip]
In its simplest form have a look at a 'C' Runimage file in !Zap.


.start_prog
mov r0,r0
mov r0,r0
mov r0,r0
bl  your_code
swi "OS_Exit"
equd end_prog - start_prog   ;Read only area size
equd 0                       ;Read write area size
equd 0                       ;debug area size
equd 0                       ;Zero init size
equd 0                       ;debug type
equd &8000                   ;start address
equd 0
equd &20                     ;32bit flag
equd 0
equd 0
equd 0
.your_code
xxx

.end_code
***********
 

-- 
Colin Ferris Cornwall UK

[toc] | [prev] | [next] | [standalone]


#588

FromBob Latham <bob@sick-of-spam.invalid>
Date2011-08-11 21:19 +0100
Message-ID<52013fd1e9bob@sick-of-spam.invalid>
In reply to#587
In article <ca8b390152.cferris@cferris.freeuk.com>,
   <cferris@freeRemoveuk.com.invalid> wrote:

> In its simplest form have a look at a 'C' Runimage file in !Zap.


> .start_prog
> mov r0,r0
> mov r0,r0
> mov r0,r0
> bl  your_code
> swi "OS_Exit"
> equd end_prog - start_prog   ;Read only area size
> equd 0                       ;Read write area size
> equd 0                       ;debug area size
> equd 0                       ;Zero init size
> equd 0                       ;debug type
> equd &8000                   ;start address
> equd 0
> equd &20                     ;32bit flag
> equd 0
> equd 0
> equd 0
> .your_code
> xxx

> .end_code
> ***********

Thanks for the information, most enlightening.

Got a couple of questions though if you don't mind.

1) Can you make the Read only area 0bytes and the read write area the
whole thing? I have variables all over the program otherwise I can't reach
them without extra pointers and far more code.

2) My Progs end like this...

 .shtdn    ADR R10,reg1
           LDR R1,[R10,#0]
           LDR R0,[R10,#4]
           SWI "Wimp_CloseDown"
           LDMFD R13!,{R0-R12,R14}
           MOV PC,R14

 and near the start....
 .reg1     EQUS"TASK":EQUD 0:ALIGN;TASK handle.

So after it has run the existing code it will return from the subroutine
and exit with swi "OS_Exit"? I take it that OS call doesn't return?

3) What's a debug type?

4) Are there any examples in code I might understand ie basic or assembler?
   I will never understand 'C' its not of my universe.


Cheers,

Bob.

-- 
Bob Latham
Stourbridge, West Midlands

[toc] | [prev] | [next] | [standalone]


#593

FromJohn Tytgat <this@is.invalid>
Date2011-08-12 12:58 +0200
Message-ID<j23114$d3u$1@dont-email.me>
In reply to#588
On 8/11/2011 10:19 PM, Bob Latham wrote:
> Thanks for the information, most enlightening.

Specification can be found at 
http://www.riscos.info/websvn/filedetails.php?repname=gccsdk&path=%2Ftrunk%2Fgcc4%2Friscos%2Fasasm%2Fdocs%2FAIF-1993

> Got a couple of questions though if you don't mind.
>
> 1) Can you make the Read only area 0bytes and the read write area the
> whole thing? I have variables all over the program otherwise I can't reach
> them without extra pointers and far more code.

Sure.

> 2) My Progs end like this...
>
>   .shtdn    ADR R10,reg1
>             LDR R1,[R10,#0]
>             LDR R0,[R10,#4]
>             SWI "Wimp_CloseDown"
>             LDMFD R13!,{R0-R12,R14}
>             MOV PC,R14
>
>   and near the start....
>   .reg1     EQUS"TASK":EQUD 0:ALIGN;TASK handle.
>
> So after it has run the existing code it will return from the subroutine
> and exit with swi "OS_Exit"? I take it that OS call doesn't return?

OS_Exit does indeed not return.

> 3) What's a debug type?

Cfr URL mentioned above.

> 4) Are there any examples in code I might understand ie basic or assembler?
>     I will never understand 'C' its not of my universe.

AIF binary format is not 'C' specific.  It is just the file format for 
every Absolute file.

John.

[toc] | [prev] | [next] | [standalone]


#595

Fromcferris@freeRemoveuk.com.invalid
Date2011-08-12 13:11 +0100
Message-ID<09f4960152.cferris@cferris.freeuk.com>
In reply to#593
In message <j23114$d3u$1@dont-email.me>
          John Tytgat <this@is.invalid> wrote:

> On 8/11/2011 10:19 PM, Bob Latham wrote:
> > Thanks for the information, most enlightening.
> 
 
[snip]

> >
> > So after it has run the existing code it will return from the
> > subroutine and exit with swi "OS_Exit"? I take it that OS call
> > doesn't return?
> 
> OS_Exit does indeed not return.

The OS_Exit in the header is I think a 'Belt & Braces' - ie not usually
used.
> 
> > 3) What's a debug type?
> 
> Cfr URL mentioned above.
> 
> > 4) Are there any examples in code I might understand ie basic or
> > assembler? I will never understand 'C' its not of my universe.
> 

Have you tried downloading the demo of 'DeskDebug' - there is a nice
program of a Multi-tasking game in Assembler.

If you are using a 26bit RO then '!Arm_Debug' (ask for latest) and
course there is '!Reporter' - they may be of some use.

Have a look at a !Runimage file (in '!Zap') - which was created by the
'C' compiler - its of course be ARM code now - it will show the AIF
header.

Drucks - '!ARMalyser' program is pretty good at disassembly - try your
programs in it.

Bye
-- 
Colin Ferris Cornwall UK

[toc] | [prev] | [next] | [standalone]


#605

Fromdruck <news@druck.org.uk>
Date2011-08-13 15:09 +0100
Message-ID<j260j9$no$4@dont-email.me>
In reply to#595
On 12/08/2011 13:11, cferris@freeRemoveuk.com.invalid wrote:
> Drucks - '!ARMalyser' program is pretty good at disassembly - try your
> programs in it.

There is also a template AIF header file in there which you can prepend 
to the ARMalyser output in order to produce a file which will be 
acceptable to RO6. Follow the good advice given here on which fields in 
the header need to be adjusted.

---druck

[toc] | [prev] | [next] | [standalone]


#589

Fromjgharston <jgh@arcade.demon.co.uk>
Date2011-08-11 15:49 -0700
Message-ID<3610e40f-3e5c-4f24-9db7-3568823c4940@o26g2000vbi.googlegroups.com>
In reply to#587
cfer wrote:
> In its simplest form have a look at a 'C' Runimage file in !Zap.
> .start_prog
> mov r0,r0
> mov r0,r0
> mov r0,r0
> bl  your_code
> swi "OS_Exit"

And a Utility header looks like this:
      REM > X32/src
      DIM mcode% &100
      FOR P=0 TO 1
        P%=&0:O%=mcode%
        [OPT P*3+4
        .start
        \ RISC OS 4 Header:
        B entry        :\ Entry point
        EQUD &79766748 :\ Magic word
        EQUD &216C6776 :\ Magic word
        EQUD end-start :\ read-only size
        EQUD 0         :\ read/write size
        EQUD 32        :\ 26-bit or 32-bit
        .entry
        MOV R0,R1      :\ Pass paramters to R0
        SWI "XOS_CLI"  :\ Execute parameters
        CMP R0,R0      :\ Clear V
        MOV PC,R14     :\ Return cleanly
        :
        EQUS "X 0.03 (04 Sep 2006) 32-bit header"
        EQUB 0:ALIGN
        .end
        ]NEXT
      OSCLI"Save X "+STR$~mcode%+" "+STR$~O%
      OSCLI"SetType X Utility"

Mutter. My previous version of 'X' was only three words long ;)

JGH

[toc] | [prev] | [next] | [standalone]


#598

FromRick Murray <heyrickmail-usenet@yahoo.co.uk>
Date2011-08-13 00:57 +0200
Message-ID<4e45afce$0$18788$ba4acef3@reader.news.orange.fr>
In reply to#584
On 11/08/2011 13:11, Bob Latham wrote:

> They all give an error message "The application uses an obsolete
> executable file format which is no longer supported by RISC OS".

Useful. I can understand your irk.


> I've looked at page 4-436 in my OS 3 PRMs and it seems to suggest I should
> be linking AOF files. This means nothing to me what_so_ever.

Yeah, well, it's simple:

C or assembler source compiles/assembles into an "object file" which is 
a mixture of code and pointers.

When all of the modules have been generated (it isn't unusual for a 
program to be upwards of twenty separate pieces of code), these object 
files are taken and rearranged into the final executable by the 
"linker", with all the branch addresses and references fixed up correctly.


> Would some kind person explain if I can provide such a thing using the
> Basic assembler which I use

Yes.

You just need to learn the header format, and then prefix it to the 
start of your software. However, note, you must be EXTREMELY careful to 
never use any code that is incompatible with 32 bit operation - if you 
tell the operating system you're compatible, but you aren't, things 
could go bang.


> and point me at something a bit more understandable than the PRMs
> if possible.

ROL's description here:
http://www.riscos.info/websvn/filedetails.php?repname=gccsdk&path=%2Ftrunk%2Fgcc4%2Friscos%2Fasasm%2Fdocs%2FAIF-1993

Much nicer description here:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0041c/ch13s03s03.html
[and if you look to the index on the left, there's more info on the AIF 
file and what it is/means/does]

Some annoyances raised here:
http://www.drobe.co.uk/article.php?id=1629&hlt=archimedes


> Sorry, if I sound unhappy, but I am.

I can imagine.


> Being able to knock up a bit of code and run it is a major reason
> why I've stayed with RISC OS.

Indeed. I wanted to play with making the smallest possible valid ARM ELF 
executable, and I discovered that the GCC compiler just *does* *not* 
spit out raw code. In the end, I resorted to a hex editor to pull out 
the code I wanted from all the object file garbage.
[if you're interested:
   http://www.heyrick.co.uk/blog/index.php?diary=20110404]


> If someone just decides to wipe that out

It sort-of makes sense to try to enforce compatibility with newer 
machines, however I'm not sure it was the smartest idea for the reason 
you've already touched on:
> even though RO is struggling for users and is having to change progs
> for 32bit and beagle etc.

That said, I think that it is a worthwhile idea. It isn't that hard to 
fake up an AIF header, and it helps to protect the integrity of the machine.



One thing I noticed when taking apart the ELF header code in ARMLinux, 
is that although a lot of fields are defined, there are some that are 
simply ignored. I wonder what the minimal *legal* AIF header would be?


I'm thinking (though in Usenet tradition - totally untested), something 
akin to:

   .entry
     MOV   R0, R0
     MOV   R0, R0
     MOV   R0, R0
     BL    start
     SWI   "OS_Exit"

     EQUD  160          ; executable, so only size of header
     EQUD  end - start  ; size of read/write area
     EQUD  0            ; debug size
     EQUD  0            ; zero-init size
     EQUD  0            ; debug type
     EQUD  &8000        ; image base address
     EQUD  0            ; workspace (obsolete)
     EQUD  32           ; addressing mode (32 = 32bit okay)
     EQUD  0            ; ? image data base address [1]
     EQUD  0            ; reserved
     EQUD  0            ; reserved
     MOV   R0, R0       ; NOP

     ; [2]

   .start
     ; your code goes in here


   .end


Try something like that.


1 - If an application with mixed code/data is used, should the
     data base address be zero or &8000? I wonder if/how it could
     affect the split code/data caching.

2 - We don't have zero-init code, nor do we branch into it at the
     top, so I'm guessing we can just skip it...


> Very microsoft - we'll control what you do/run on your machine, we
> know better than you.

I think these days "Microsoft" should be replaced with "Apple".


Best wishes,

Rick.

PS: While looking for resources, I came across this thread
     ripped from usenet and dumped on a content recycler...
     http://www.freak-search.com/en/thread/5463045/aif_header_how

[toc] | [prev] | [next] | [standalone]


#601

FromBob Latham <bob@sick-of-spam.invalid>
Date2011-08-13 10:42 +0100
Message-ID<52020d2704bob@sick-of-spam.invalid>
In reply to#584
A Quick thanks to everyone who took the time to offer advise and
information about this (PITA) issue. I'll have a good read of all the
material I've been pointed at and then have a go.

It is much appreciated.

Cheers,

Bob.

-- 
Bob Latham
Stourbridge, West Midlands

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.acorn.programmer


csiph-web