Need help interfacing Gnu "as" to fpc (very specific)



The question I have now is a little complicated.
I may not even have to write the code I'm thinking about
to accomplish my goal. (i.e there may be another way)

1. I would like the ability to link an arbitrary binary
file into an executable as a data object i.e. Variable or Constant.
(final result: a cgi app that contains its own small icons either
gif/png or jpeg
would even work with flash or sound though large files would be
impractical)
(Under Turbo I could do this with bin2obj)

2. Under windows I can probably use resource files but the syntax is
a little to complex for my tastes. I would like to employ the same
approach under windows and linux if possible (the pascal web unit
is cross platform from the start)

3. I used to do some work in MASM years ago. For a couple of
days I have been looking at AT&T syntax for the Gnu assembler
and looking at the .s output of a couple of fpc compiles.

4. PLAN
1. write pascal program bin2o_gnu
// possibly exists already ??
that
a. parses an arbitrary binary file into a series of
.byte statements in an assembler file
(with the appropriate header information first)
// I don't need help here I am sufficiently
skilled to do this. The header is the problem

b. passes this information to Gnu "as" to create .o
file
(write out text file for development so I can
inspect .s headers and change them if
necessary until it works, uses shell() to
call 'as' when fully working use
Assignstream or POpen
and pipe it the code.)

c. Since the thrust of this is for a development
library Next step is to auto generate a
Pascal unit .pp/.pas file
That supplies a public pointer to the linked in
buffer.
// Once I get the asm done
// this will probably be simple.


(In the spirit of free software the generated unit will also
have the procedure Recreate_Original_File)

5. ACTUAL QUESTION:
I'm a little confused about the .global directives and naming
conventions I need to use under the assembler to make the
buffer visible in fpc. The prepending and casing is
confusing me somewhat. Also though I am familiar
with the pascal syntax for external procedures I'm not sure
if the 'external' keyword works for variables.

I would really like 3 public identifiers in the asm/ .s file
The size of the original binary : LongWord
The original filename (no path) : string; (Pchar ???)
The buffer itself.

Any help here would be appreciated. The problem right now
is to much information. I have no desire to become a Gnu
"as" expert but I'm starting to feel that way after wading
through the huge amounts of info Google is feeding me,
without finding the specifics I need.

Thank You,
Tony
.



Relevant Pages

  • Re: Ancient history
    ... this environments... ... they involve exclusive assembler implementation. ... with explicit buffer lengths as part of the normal infrastructure ... ... programmer to manage buffer lengths). ...
    (sci.crypt)
  • Re: In-tree version of new FireWire drivers available
    ... Just to recap, the dual buffer receive mode, as described in section ... quadlet aligned amount of header data can be appended into one buffer ... *either* the header buffer or the payload buffer fills up. ... enough to hold headers for all the packets it takes to fill up the ...
    (Linux-Kernel)
  • [Full-disclosure] n.runs-SA-2009.001 - OS X CFNetwork advisory
    ... 2009/04/17 Initial notification of Apple including n.runs RFP ... A remotely exploitable vulnerability has been found in the HTTP header ... result is either stored in a local stack buffer or in a buffer ... the vulnerability allows remote code ...
    (Full-Disclosure)
  • n.runs-SA-2009.001 - OS X CFNetwork advisory
    ... 2009/04/17 Initial notification of Apple including n.runs RFP ... A remotely exploitable vulnerability has been found in the HTTP header ... result is either stored in a local stack buffer or in a buffer ... the vulnerability allows remote code ...
    (Bugtraq)
  • Re: Making HLA even more high-level.
    ... We have a header in the ... Problem with this approach is that it doesn't cater endianess. ... This isn't assembler, true, but I don't use assembler for *everything*, ... endianess conversion decision at runtime is eliminated. ...
    (alt.lang.asm)