As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I read that an executable stores the code in different sections. For example, a separate section for data etc. Is this generic across different platforms such as Win or MacOs or Linux?
Some insight into it would be really helpful.
You are correct in that an executable has several sections or segments: Not all of them, however, are code.
There is usually one segment for code - in ELF and PE, this is usually called .text. Additional ones exist to store dynamic linkage data, hard coded strings, read only data, global variables, etc.
To see these for yourself, rather than Wiki and Google , try hands on:
In Windows: You have a tool called DUMPBIN.EXE , part of visual studio. If you can't get your hands on that, use Dependency Walker (which is freely downloadable). This will parse PE and PE32+ (that is, 64-bit) files
In Linux: Use objdump -x , or readelf (both are pretty much the same, though with slightly different options) for ELF files.
In Mac: Use otool -l to see the load commands (which show you the sections and the segments) in Mach-O files.
Using either or all tools will hopefully get you a better idea of how things work.
Hope this helps,
TG
Windows uses Portable Executable format.
*nix generally uses Executable and Linkable Format. Previously some used SOM, a.out, ECOFF, XCOFF, COFF, and some others.
OS X and iOS (and NeXT, history fans) uses Mach-O.
PowerPC systems still support Preferred Executable Format which was used with earlier Mac OSs, and some forms of BeOS.
Maybe start with http://en.wikipedia.org/wiki/Comparison_of_executable_file_formats
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Just for the hell of it, i've taken an interest in learning assembly. The problem is I can't find a good starting point...
There seems to be a lot of assemblers available (FASM, NASM, YASM, MASM) but each has their own separate syntax, commands, and features. FASM seems to be the most convenient since it can compile executables without a linker but I haven't been able to find any tutorials to start me off. All the "Hello World" examples i've seen are 16 or 32-bit, but i'm running on 64-bit Windows so none of them work. The Windows examples included with FASM work but I'm not looking to get into Windows programming right from the start, I want to grasp the basics first.
Can anyone point me in the right direction?
If you want to learn to read assembly, I recommend learning to use WInDbg or IDA Pro as your primary debugger - learning not only what the instructions do, but how a C++ compiler idiomatically translates your source code into assembly will help you to learn far better than if you're doing contrived 100% assembly examples
I am no expert on assembly but it is an essential thing, to at least be familiar with, in computing. In a computer engineering class we used SPIM by James Laurus, a MIPS architecture simulator for windows. I think it is a good starting point. You can find a MIPS cheat-sheet via Google search, as well as some tutorials.
Assembly is cool because it is essentially machine language. Happy hacking!
32-bit examples should work even though your host OS is 64-bit.
On top of that is the difference between a 32- and a 64-bit Hello World just 2 characters:
include 'win64ax.inc'
vs
include 'win32ax.inc'
This is the best x86 ASM introduction I have found:
http://www.drpaulcarter.com/pcasm/
There is a pdf version of his book on that page. It starts at the very basics and works its way up. I got all of the fundamental ASM knowledge that I needed just with this book (stack frame creation, calling conventions, c interop, just to name a couple).
It's just boring to learn assembler without any goal.
Could I recommend you to buy any robot kit? As I know RoboSavvy robots are managed by assmeblers / C .. Others may have only DSL.
http://robosavvy.com/site/
P.S. I've learned assembler when I was in need to cheat in games. But today I would choose robot kits.
If you are a bigner and wants to learn the assembly better to get ASM knowledge 1st.
secondly try to learn the basic logic behind each code.
3.enjoy the language when try to learn if u r intrested otherwise leave it.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have written code to compress and decompress image files using a proprietary SDK for transmission from an aircraft via satellite. Unfortunately a license must be purchased for decompression as well as compression. Until now my applications have been mostly used in-house so I can keep track of the licenses and distribution. Now I need to provide the applications for outsiders and I can neither control distribution nor want to pay for the licenses.
Does anyone know of free de-compression programs, SDKs, or libraries? I program in C++ for Windows NT, 2000, XP.
My image files are raw data, monochrome, with 16bit unsigned pixels and the compression that is used is lossless or very mildly lossy.
It's just a thought, but the de facto standard for JPEG2000 is Kakadu because Dr. Taubman pretty much wrote the JPEG2000 standard. Although it costs some money, it is the best library that I know of.
Maybe this could be a good starting point: OpenJPEG. If it doesn't meet your requirements then ask at their forum for some hints.
Some people at my university used jj2000 for various tests. However it is in Java...
also libjasper: link text
Check out j2k-codec It's not free but not expensive either.
I've bought it (v1.7) myself and been using it for 4 years. Decoding is very fast, no error encountered so far.
For encoding, I use ER Mapper SDK.
I don't know how much improvements Jasper or OpenJPEG has shown these years, but those free libraries were too slow for my use. (Both encoding and decoding slow)
Magick++ is a C++ binding for ImageMagick that I think exposes ImageMagick's JPEG-2000 functionality. ImageMagick uses libjasper, which Doug mentioned. This might do the trick for you (and hopefully for me, too).
Why would anyone tagetting the windows platform pay someone for a Jpeg library when GdiPlus does it already?
http://msdn.microsoft.com/en-us/library/ms533844(VS.85).aspx
should be a good starting point. gdiplus has the 2nd best jpeg decompression speedwise (in my tests for whatever that counts for). And is distributed as an OS component with Windows 5 and up. i.e. Windows XP and greater.
If, for any reason, GdiPlus is unacceptable...
Intel used to distribute a jpeg decompression * compression library, inventively named the "intel jepg library" or ijl. the redistributable consists of a single dll, ijl15.dll
If you can find the original distribution, its licensed for free distribution and use. Intel just dont host it any more. Its been replaced with the intel performance primitives library, which does contain jpeg compression and decompression, but the per seat licensing is very fair, and again theres no limit on redistribution of the coff redistributables.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Does anyone have any recommendations for a good, fast, make tool? SCons? KJam? Something else?
Cross platform tools would also be acceptable.
GNU make is fast, but the native Windows-port is not very polished; there are a lot of pitfal regarding things like which shell is used to execute your commands. (Search for "MS-DOS" in the GNU make manual.)
SCons works very well on Windows. SCons had (last time I looked) some serious performance issues on large projects (thousands of files and upwards), but that was a couple of years ago.
CMake is an excellent tool if you want to work in Visual Studio but still stay crossplatform and allow other development tools on other platform. Can also generate makefiles for windows, so you're not bound to Visual Studio.
Whatever you may think of Ant, it is not a replacement for Make. That's like saying that a SUV is a replacement for a Formula 1 car. They are entirely different beasts. Ant is good for some things, and make for others.
There is a relatively new tool called premake which you may want to investigate. It looked promisiing when I looked, but I haven't checked it out in any detail.
On a PC is said in your title, so I assume you mean Windows? If so, I would recommend installing the Cygwin environment and if you install all the packages along with it, GNU's make is part of the deal. If you are on a Linux platform or one of the Unix variants, then you can just go with the GNU make directly.
You may be interested in cross-platform tools like Ant, Rake, Gant. These should give you most, if not all the functionality of GNU make, though compiling C code may be harder in some than other.
I've recently started using BJam. It is cross-platform and has a saner syntax than make.
If you're on Windows and you have the .Net Framework, you can use MSBuild. It's very similar to nAnt, and also has a lot of support from the community (some very detailed community toolkits are out there). It has a somewhat steep learning curve, but it's quite powerful once you get the hang of it.
Also another option could be writing PowerShell scripts. It depends what you want to do I guess. In my limited experience with makefiles, they've usually be to compile something, or set environment conditions, which you would use batch files for on a Windows platform.
If you need to build C-language based projects, take a look at rtEasyMake at www.routinetools.com. It is windows based and very easy to setup.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'd like to learn assembler. However, there are very few resources for doing assembler with OS X.
Is there anyone out there who has programmed in assembly on a Mac? Where did you learn?
And, is there any reason I shouldn't be doing assembly? Do I risk (significantly) crashing my computer irreparably?
If you're using a PowerPC Mac, look into gcc inline assembler. Otherwise, look into nasm. I can't give any decent references to PPC ASM (they're few and far between), but I suggest the following things to learn x86 asm:
The book Reversing by Eldad Eilam
Compile simple C source with gcc -S and read the assembly generated
Use Sandpile
Join #openrce on irc.freenode.net and use OpenRCE
Also, if you're not in kernel mode then there's no chance of screwing anything up, really, and even if you are in kernel mode it's hard to really destroy anything.
Edit: Also, get gcc and such from XCode not Macports or somesuch. You're in for a world of malformed Mach-O files if you don't. Not fun to diagnose file format issues when you're just starting asm hacking.
The assembler language is determined by the hardware platform, not the operating system. Given that OS X runs on Intel platform and is 64-bit, you should look for information on x64 (also called AMD64) assembler. Check the Wikipedia article (http://en.wikipedia.org/wiki/X86-64) for a lot of links to documentation about x64.
Also, the OS X tools documentation might contains a lot of information about x64 assembler. In particular, the Netwide Assembler (NASM - http://developer.apple.com/documentation/DeveloperTools/nasm/nasmdoc0.html) might have documentation on how to build OS X applications using assembler.
To start learning assembly, you might want to start with simple C programs and ask GCC to generate the assembler code for it using the -S option:
gcc -S hello.c -o hello.asm
You will then be able to understand how to call functions, pass arguments, etc.
Nasm/yasm are your best bet; gcc inline syntax is quite crippling and can be very painful to use at times, plus there are literally some things it cannot do. Nasm's macro syntax is also much much more useful, a godsend in a language like assembly that has no built-in templating features.
XCode (ie. GCC) has great support for writing assembler. It's a fun thing to learn (although you're unlikely to need it much), and the worst you can do is crash the program you're writing, same as in C. Just Google for 'gcc inline asm x86 tutorial' and you should find plenty of starting points. Don't worry that some will seem to be Linux specific, they'll generally work just as well in XCode.
(edit) ...assuming you have an Intel Mac of course; if not then replace 'x86' with 'ppc'.
here
I programmed assembly on a Mac. It was Motorola 680x0 assembler using MPW. I've touched on the PowerPC assembler a few times in CodeWarrior and ProjectBuilder. Now ProjectBuilder is called XCode, and there is Intel. The assembler is one of the many tools within XCode.
I originally learned assembler on the Apple II: the 6502 machine language monitor built in ROM, the Sweet16 mini-assembler, and others. Later, I used Intel 80186 assembler to speed up slow bits of C code, and work paid for a one day course on Intel 80186 assembler at a university. Later, I had to maintain some 680x0 assembly for the Mac. That was a long time ago.
I don't think there is any reason not to do assembly. Learning is great. Learn all you can. Drop into a low enough level debugger and look at the disassembled code.
My advice is:
Don't be scared.
There's no reason why you shouldn't; there is nothing you can do in assembly language that you can't do in a higher level language like C.
As far as tools go, you might want to install MacPorts and get the GNU assembler. That may or may not be the easiest way, but it's free and you can probably find tutorial documentation for writing Unix programs in GNU assembler somewhere on the net.
There are two three things you to know need for writing assembly language on a system with an operating system (as opposed to 'bare metal' assembly which is a world of its own):
How the instruction set works - loads of resources for Intel X86 if you have an Intel Mac, still reasonable set for PPC for example Mac OS X Internals.
How to assemble link your programmes - if you have the Developer tools installed you have GCC and associated tools
How to talk to the OS - here is where Mac assembly is a lot less well documented than Windows or Linux. It may be you have to write equivalent C programs and use 'gcc -S' to see what calling/stack restoration conventions are appropriate. It depends what you want to do but at a miniumum you need OS system calls for IO and memory allocation.
A good starting point is here.
If you've got Developer Tools installed, you can simply open Terminal and type as (GNU Assembler - part of Binutils).
For PPC try Lightsoft
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
What is the best compilable scripting language for Win32? I prefer .EXE's because I don't want to install the runtime on the servers first (my company administrates many via remote), but I need to be able to do things like NTFS permissions and (if possible) APIs over the network.
There was a small Perl which appeared to be able to do most of this, but it does not seem to have been updated/developed in quite a while. I have wondered about Lua, but I don't know if it has everything I need yet (and don't want to hunt through fifty library sites trying to find out). Any thoughts?
Have you considered using an EXE maker? For example, you can code in Python and use py2exe to create a standalone EXE that runs anywhere (it actually packages Python into the exe, so you don't have to install the runtime).
Ruby is my scripting language of choice.
Try RubyScript2Exe.
A scripting language is, almost by definition, not compiled into a standalone executable. So maybe you need to restate your intentions or give some indication about what kind of program you want to create.
C# is a powerful language that compiles to .EXE and allows you to interface with pretty much anything (through native p/invoke calls, if necessary). A basic but very usable Visual Studio for C# can be downloaded for free from the Microsoft website. The .NET runtime is installed on most systems nowadays.
Did you consider AutoIt ?
It is a scripting language, and you can quickly transform a script into an exe...
At OSCON 2005, I heard Damien Conway say "the only thing better than Perl is something that works well, even if it's not written in Perl."
It's good advice. Instead of looking for the best language that can be compiled to an .EXE, worry a lot more about writing it in a language that can be compiled to an .EXE. Use whatever works. Just remember that the quality of your programming matters infinitely more than what language you use.
That said, I like py2exe. YMMV. Good luck!