• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
fir

raw binary to obj conversion

19 posts in this topic

 
 

I wonder if in such case i get a .bin file with the raw contents of some procedure (x86-32) is it possible to convert this with some tool (or if it is at all possible) to some linkable object file (like coff) which i can link and use (for example with GCC)

Speciffically it seem to me that when converting i shoulf gabe some export symbol name, dont know what with import symbol names, also do not know if some reallocation table would be needed to use this with such bonary or it is not needed and can be build at the process of conversion, i dont manage to understand what is going on with this realocation data

is it possible to convert data such way? could someone explain this?

 

0

Share this post


Link to post
Share on other sites

Have you looked into disassemblers?

 

I use them sometimes but this is somethink different..

 

I need an avaliable converter (bin->obj) or i need to wrote some converter code by myself but im not sure how hard it is ad what exactly need to do (would like need to know which one of obj formats is most easy to easily wrote some code for saving this)

0

Share this post


Link to post
Share on other sites

Check out objcopy from gnu binutils. I used it many times to generate raw firmwares from objs (obj -> bin). It should work the other way, but if it doesn't, just write a simple script to generate C file with data as global array.

2

Share this post


Link to post
Share on other sites

Check out objcopy from gnu binutils. I used it many times to generate raw firmwares from objs (obj -> bin). It should work the other way, but if it doesn't, just write a simple script to generate C file with data as global array.

 

 what do you mean? I dont want to use assembler, compiler or something like that 

want to have a tool for converting bin->obj (othar way is much easier for example nasm can produce bin only, or other tools can strip obj to binary too) - and much preferably understand how this conversion in details look like

 

i would later need a way of generating binary object files by myself from c code (try to wrote some very simple assembler elements) but dont know what of the common object formats would be easier to generate

 

right now im thinking about just generating .bin and converting it on linker 'toolchain' side, but would like to get some help with all of this

0

Share this post


Link to post
Share on other sites

Assemblers and compilers are the tools to generate object files.

If you want to generate it in another fine way, write the tool yourself. Look into the specifications for the various object file formats and choose one to implement. Should not be very hard with your experiences.

 

Generating a bin file from objects is called linking. For embedded systems you often have an additional step of locating, because the different sections defined in an object file needs to be moved into the right memory addresses.

 

If someone needs an image file or some binary data within his/her application they use their application development environment and put it in as data. The toolchain do the rest. So it would be surprising if someone would need a special tool to create an object file from a binary.

2

Share this post


Link to post
Share on other sites

Assemblers and compilers are the tools to generate object files.

If you want to generate it in another fine way, write the tool yourself. Look into the specifications for the various object file formats and choose one to implement. Should not be very hard with your experiences.

 

Generating a bin file from objects is called linking. For embedded systems you often have an additional step of locating, because the different sections defined in an object file needs to be moved into the right memory addresses.

 

If someone needs an image file or some binary data within his/her application they use their application development environment and put it in as data. The toolchain do the rest. So it would be surprising if someone would need a special tool to create an object file from a binary.

 

i got moderate experience - generating .obj myself is possible

but depends what you mean "not so hard" those are complex formats with many variable size chunks and other stuff so this is considerable more work to succesfully go thru that 

 

need at least some hints which format could be easier one to chose, 

or some hints what i would need to code (and how to make it easy) when writing such kind bin->obj "enveloper" or conventer

0

Share this post


Link to post
Share on other sites

It depends completly on your experiences. Take a look into the specifications. There you find all information you need to make a decission.

1

Share this post


Link to post
Share on other sites

Have you evaluated GNU's Binary File Descriptor library referenced in the Wikipedia article?

need something opposite - not variety of 50 formats but info how to generate the only one but as simplest as possible (or even some ready tool as i said - will read on this but its a mountain of docs on this but not exactly the substantial answer i need to find)

 

(the substantial question is : "i got an .bin with some procedure contents - how exactly to do it in an easier way to make some object from that"

 

(i need more some more like quick workable hack than extensible code)

0

Share this post


Link to post
Share on other sites

It depends completly on your experiences. Take a look into the specifications. There you find all information you need to make a decission.

 

I think you should quit this pseudo answers , when someone os asking specific questions, such answer like "go googling" or "go reading dosc" are not valuable at all - so really better not answer at all - Im not sure if i had option to block you but if you will repeating such way i will filter you out

-9

Share this post


Link to post
Share on other sites

Take awk to make a assembler source and let the assembler create the obj file. This way you are able to set the symbol-table as well. No need to read extensive documentation.

 

We are again at a point where you refuse to do the obvious. The BFD library is the easiest way to access the obj-file content. It is complex because the file format is complex and you complain about the complexity.

Using an assembler, that is made to come around the complexity of creating obj files, is neither an option for you. So what you expect as an answer. If you want a quick hack, make it yourself. Look into the object file format specification and select the things you need, hardcode the sections of the file and merge in your bin file.

Thats an easy task. I did wrote a fileconverter for object files 20 years ago and needed not very long for it.

0

Share this post


Link to post
Share on other sites

 

It depends completly on your experiences. Take a look into the specifications. There you find all information you need to make a decission.

 

I think you should quit this pseudo answers , when someone os asking specific questions, such answer like "go googling" or "go reading dosc" are not valuable at all - so really better not answer at all - Im not sure if i had option to block you but if you will repeating such way i will filter you out

 

 

I thought you were going to filter this entire site out and leave. At least that's what you promised to do.

0

Share this post


Link to post
Share on other sites
[quote name="LennyLen" post="5165493" timestamp="1404809588"]

I thought you were going to filter this entire site out and leave. At least that's what you promised to do.[/quote]

Not entire, some people can answer precise question, but such stuff as above is not an answer so dont want to be crude but i will filter you out with pleasure same as tribad - If you are not able to answer i think you should will not produce trash answers - go on topic

[quote name="Tribad" post="5165492" timestamp="1404809276"]

So you expect that others read the specification and tell you what to do? Sounds like that. Because you do not ask specifics about the format, this is the first answer to give. Read the doc. If you do not understand parts of it, ask for help. Thats the way it works.


But not asking for help and refuse to read the first information source available, the specification.[/quote]

Man, get a little wiser - I am NOT expecting anyone to read a docs specifically for me to only fullfill my needs as i would be a king or something - get sober
It is more like s[size=4]ome people are arleady experienced and can just share some hint, it often works that way - and then its good way of using forums[/size]
-2

Share this post


Link to post
Share on other sites

All users (including you fir!) please keep your replies polite and on topic.

 

This topic will be closed if it isn't kept on-point, and any offending members will be warned as appropriate.

 

(...and please note that staying on topic includes not responding to this post.  I can be contacted via private message or a discussion can be started in the "Comments, Suggestions & Ideas" forum if anyone wants to comment on my moderation.)

2

Share this post


Link to post
Share on other sites

 

Check out objcopy from gnu binutils. I used it many times to generate raw firmwares from objs (obj -> bin). It should work the other way, but if it doesn't, just write a simple script to generate C file with data as global array.

 

 what do you mean? I dont want to use assembler, compiler or something like that 

want to have a tool for converting bin->obj (othar way is much easier for example nasm can produce bin only, or other tools can strip obj to binary too) - and much preferably understand how this conversion in details look like

 

 

Have you actually checked out the objcopy docs? Because it is the right tool for this job. You might need some extra options to get the exact symbol table you need, but a framework of a solution might look like this:

wojtek@wojtek-VirtualBox:~/Desktop$ objcopy -I binary -O elf32-i386 --rename-section .data=.text --redefine-sym _binary_bla_bin_start=_my_raw_code bla.bin bla.o 
wojtek@wojtek-VirtualBox:~/Desktop$ objdump bla.o -x

bla.o:     file format elf32-little
bla.o
architecture: UNKNOWN!, flags 0x00000010:
HAS_SYMS
start address 0x00000000

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000000a  00000000  00000000  00000034  2**0
                  CONTENTS, ALLOC, LOAD, DATA
SYMBOL TABLE:
00000000 l    d  .text  00000000 .text
00000000 g       .text  00000000 _my_raw_code
0000000a g       .text  00000000 _binary_bla_bin_end
0000000a g       *ABS*  00000000 _binary_bla_bin_size

It's not elegant or finished right now, but just an example that you can do everything with objcopy.

1

Share this post


Link to post
Share on other sites

 

 

Check out objcopy from gnu binutils. I used it many times to generate raw firmwares from objs (obj -> bin). It should work the other way, but if it doesn't, just write a simple script to generate C file with data as global array.

 

 what do you mean? I dont want to use assembler, compiler or something like that 

want to have a tool for converting bin->obj (othar way is much easier for example nasm can produce bin only, or other tools can strip obj to binary too) - and much preferably understand how this conversion in details look like

 

 

Have you actually checked out the objcopy docs? Because it is the right tool for this job. You might need some extra options to get the exact symbol table you need, but a framework of a solution might look like this:

wojtek@wojtek-VirtualBox:~/Desktop$ objcopy -I binary -O elf32-i386 --rename-section .data=.text --redefine-sym _binary_bla_bin_start=_my_raw_code bla.bin bla.o 
wojtek@wojtek-VirtualBox:~/Desktop$ objdump bla.o -x

bla.o:     file format elf32-little
bla.o
architecture: UNKNOWN!, flags 0x00000010:
HAS_SYMS
start address 0x00000000

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000000a  00000000  00000000  00000034  2**0
                  CONTENTS, ALLOC, LOAD, DATA
SYMBOL TABLE:
00000000 l    d  .text  00000000 .text
00000000 g       .text  00000000 _my_raw_code
0000000a g       .text  00000000 _binary_bla_bin_end
0000000a g       *ABS*  00000000 _binary_bla_bin_size

It's not elegant or finished right now, but just an example that you can do everything with objcopy.

 

allright, not checked yet (gots a tons of stuff but it is not easy to go to the point), some more on topic hints will be yet welcome - tnx 

 

does maybe someone know which format (except bin who i think is not quite linkable) could be te the easiest? or the tool to convertung bin to some linkable? Could you maybe yet explain a bit what is in this frame? Im always happy to talk in some details on this stuff im interested in

 

edit 

 

ok if it would be working it would be ok, tnx for info - that could be good if this is really working - i would try to generate pure bin with nasm then convert such way then link then i giove info if it works, tnx for hint

Edited by fir
0

Share this post


Link to post
Share on other sites
 

Have you actually checked out the objcopy docs? Because it is the right tool for this job. You might need some extra options to get the exact symbol table you need, but a framework of a solution might look like this:

objcopy -I binary -O elf32-i386 --rename-section .data=.text --redefine-sym _binary_bla_bin_start=_my_raw_code bla.bin bla.o

 

I checked it but it is aggreviating work becouse this obj copy has no examples not enumerates possible options - aggreviating thing 

 

i used 

 

objcopy -I binary -O elf32-i386 --rename-section .data=.text,alloc,load,readonly,code,contents --redefine-sym _binary_tezt_bin_start=_my_raw_code  tezt.bin tezt.o

 

and get

; Disassembly of file: tezt.o
; Wed Jul 09 09:54:46 2014
; Mode: 32 bits
; Syntax: YASM/NASM
; Instruction set: SSE2
 
 
global _binary_tezt_bin_size
global _my_raw_code
global _binary_tezt_bin_end
 
_binary_tezt_bin_size equ 00000018H                     ; 24
 
 
SECTION .text   align=1 execute                         ; section number 1, code
 
_my_raw_code:; Function begin
        mov     edx, dword [esp+4H]                     ; 0000 _ 8B. 54 24, 04
        mov     ecx, dword [esp+8H]                     ; 0004 _ 8B. 4C 24, 08
        xorps   xmm0, xmm0                              ; 0008 _ 0F 57. C0
?_001:  movdqu  oword [edx], xmm0                       ; 000B _ F3: 0F 7F. 02
        add     edx, 16                                 ; 000F _ 83. C2, 10
        sub     ecx, 16                                 ; 0012 _ 83. E9, 10
        jg      ?_001                                   ; 0015 _ 7F, F4
        ret                                             ; 0017 _ C3
; _my_raw_code End of function
 
where reference .obj file (assembled from source to win32coff without binary stage) is
 
 

 Disassembly of file: tezt.obj
; Wed Jul 09 09:49:29 2014
; Mode: 32 bits
; Syntax: YASM/NASM
; Instruction set: SSE2
 
 
extern loop11                                           ; byte
extern ZeroMemorySSE                                    ; byte
 
.absolut equ 00000000H                                  ; 0
@feat.00 equ 00000001H                                  ; 1
 
 
SECTION .text   align=16 execute                        ; section number 1, code
 
.text:  ; Local function
        mov     edx, dword [esp+4H]                     ; 0000 _ 8B. 54 24, 04
        mov     ecx, dword [esp+8H]                     ; 0004 _ 8B. 4C 24, 08
        xorps   xmm0, xmm0                              ; 0008 _ 0F 57. C0
?_001:  movdqu  oword [edx], xmm0                       ; 000B _ F3: 0F 7F. 02
        add     edx, 16                                 ; 000F _ 83. C2, 10
        sub     ecx, 16                                 ; 0012 _ 83. E9, 10
        jg      ?_001                                   ; 0015 _ 7F, F4
        ret                                             ; 0017 _ C3
 

 

so it seems like it mostly works but i dont know what is with this alignment - i see no option to set it to 16...

Edited by fir
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0