Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

C/C++ compiled program structure

NavicNavic Member Posts: 109
What would I need to know about programs written and compiled with C/C++ to process them on a ASM level. Eg. how does the Windows kernel handle a C/C++ program? How would a UNIX kernel handle and run a C/C++ program? Mostly stuff like inital memory values, disassembly of C/C++ compiled code and what happens when a C/C++ program is finished running?
NavicLand
http://www.angelfire.com/geek/navicland/index.html

HeavenWare Solutions
http://www.angelfire.com/biz7/joltware/heavenware/index.html

Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:31[/red][/b][hr]
    [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:14[/red][/b][hr]
    : What would I need to know about programs written and compiled with C/C++ to process them on a ASM level. Eg. how does the Windows kernel handle a C/C++ program? How would a UNIX kernel handle and run a C/C++ program? Mostly stuff like inital memory values, disassembly of C/C++ compiled code and what happens when a C/C++ program is finished running?
    : NavicLand
    : http://www.angelfire.com/geek/navicland/index.html
    :
    : HeavenWare Solutions
    : http://www.angelfire.com/biz7/joltware/heavenware/index.html
    :
    [blue]The compiled program (EXE or DLL) is a pure ASM. Every system has a compiler associated with it. You can't run the EXE compiled in Windows under UNIX. Somehow, I do not get what are you asking?.. When you talk about completed program - there is no C/C++. C/C++ is just a method to convert your ideas into the binary code (ASM) which can be ran on a system where you compile it.[/blue]




  • NavicNavic Member Posts: 109
    : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:31[/red][/b][hr]
    : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:14[/red][/b][hr]
    : : What would I need to know about programs written and compiled with C/C++ to process them on a ASM level. Eg. how does the Windows kernel handle a C/C++ program? How would a UNIX kernel handle and run a C/C++ program? Mostly stuff like inital memory values, disassembly of C/C++ compiled code and what happens when a C/C++ program is finished running?
    : : NavicLand
    : : http://www.angelfire.com/geek/navicland/index.html
    : :
    : : HeavenWare Solutions
    : : http://www.angelfire.com/biz7/joltware/heavenware/index.html
    : :
    : [blue]The compiled program (EXE or DLL) is a pure ASM. Every system has a compiler associated with it. You can't run the EXE compiled in Windows under UNIX. Somehow, I do not get what are you asking?.. When you talk about completed program - there is no C/C++. C/C++ is just a method to convert your ideas into the binary code (ASM) which can be ran on a system where you compile it.[/blue]
    :
    :
    :
    :
    :
    Ok, so a compiler in Windows would make the ASM code so the Windows kernel can assign and load the program into free memory, and when the program is finished executing, the Windows C/C++ compiler writes what the Windows kernel needs to know the program has terminated?
    NavicLand
    http://www.angelfire.com/geek/navicland/index.html

    HeavenWare Solutions
    http://www.angelfire.com/biz7/joltware/heavenware/index.html

  • tsagldtsagld Member Posts: 621
    : : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:31[/red][/b][hr]
    : : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:14[/red][/b][hr]
    : : : What would I need to know about programs written and compiled with C/C++ to process them on a ASM level. Eg. how does the Windows kernel handle a C/C++ program? How would a UNIX kernel handle and run a C/C++ program? Mostly stuff like inital memory values, disassembly of C/C++ compiled code and what happens when a C/C++ program is finished running?
    : : : NavicLand
    : : : http://www.angelfire.com/geek/navicland/index.html
    : : :
    : : : HeavenWare Solutions
    : : : http://www.angelfire.com/biz7/joltware/heavenware/index.html
    : : :
    : : [blue]The compiled program (EXE or DLL) is a pure ASM. Every system has a compiler associated with it. You can't run the EXE compiled in Windows under UNIX. Somehow, I do not get what are you asking?.. When you talk about completed program - there is no C/C++. C/C++ is just a method to convert your ideas into the binary code (ASM) which can be ran on a system where you compile it.[/blue]
    : :
    : :
    : :
    : :
    : :
    : Ok, so a compiler in Windows would make the ASM code so the Windows kernel can assign and load the program into free memory, and when the program is finished executing, the Windows C/C++ compiler writes what the Windows kernel needs to know the program has terminated?
    : NavicLand
    : http://www.angelfire.com/geek/navicland/index.html
    :
    : HeavenWare Solutions
    : http://www.angelfire.com/biz7/joltware/heavenware/index.html
    :
    :
    Exactly.

    Greets,
    Eric Goldstein
    www.gvh-maatwerk.nl

  • PetrusPetrus Member Posts: 10
    : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:31[/red][/b][hr]
    : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:14[/red][/b][hr]
    : : What would I need to know about programs written and compiled with C/C++ to process them on a ASM level. Eg. how does the Windows kernel handle a C/C++ program? How would a UNIX kernel handle and run a C/C++ program? Mostly stuff like inital memory values, disassembly of C/C++ compiled code and what happens when a C/C++ program is finished running?
    : : NavicLand
    : : http://www.angelfire.com/geek/navicland/index.html
    : :
    : : HeavenWare Solutions
    : : http://www.angelfire.com/biz7/joltware/heavenware/index.html
    : :
    : [blue]The compiled program (EXE or DLL) is a pure ASM. Every system has a compiler associated with it. You can't run the EXE compiled in Windows under UNIX. Somehow, I do not get what are you asking?.. When you talk about completed program - there is no C/C++. C/C++ is just a method to convert your ideas into the binary code (ASM) which can be ran on a system where you compile it.[/blue]
    :
    :
    :
    :
    :
    I think what you are looking for is the Program Segment Prefix (PSP) in DOS and its equivalent in Windows and Unix.

    In DOS, all exe are prefixed with the PSP which tells the system a bunch of things as far as running the exe itself. The PSP is not part of your source code, but added by the compiler given that the compiler knows that the target exe is a DOS exe. Now I believe if your compiler's target is different OS, it would do (add?) different "PSP".

    For the DOS PSP, go to the web, look for "program segment prefix".

    Hope this helps.

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:31[/red][/b][hr]
    : : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:14[/red][/b][hr]
    : : : What would I need to know about programs written and compiled with C/C++ to process them on a ASM level. Eg. how does the Windows kernel handle a C/C++ program? How would a UNIX kernel handle and run a C/C++ program? Mostly stuff like inital memory values, disassembly of C/C++ compiled code and what happens when a C/C++ program is finished running?
    : : : NavicLand
    : : : http://www.angelfire.com/geek/navicland/index.html
    : : :
    : : : HeavenWare Solutions
    : : : http://www.angelfire.com/biz7/joltware/heavenware/index.html
    : : :
    : : [blue]The compiled program (EXE or DLL) is a pure ASM. Every system has a compiler associated with it. You can't run the EXE compiled in Windows under UNIX. Somehow, I do not get what are you asking?.. When you talk about completed program - there is no C/C++. C/C++ is just a method to convert your ideas into the binary code (ASM) which can be ran on a system where you compile it.[/blue]
    : :
    : :
    : :
    : :
    : :
    : I think what you are looking for is the Program Segment Prefix (PSP) in DOS and its equivalent in Windows and Unix.
    :
    : In DOS, all exe are prefixed with the PSP which tells the system a bunch of things as far as running the exe itself. The PSP is not part of your source code, but [red]added by the compiler[/red] given that the compiler knows that the target exe is a DOS exe. Now I believe if your compiler's target is different OS, it would do (add?) different "PSP".
    :
    : For the DOS PSP, go to the web, look for "program segment prefix".
    :
    : Hope this helps.
    :
    :
    [blue]PSP is added by the DOS program loader.[/blue]
  • NavicNavic Member Posts: 109
    PSP is exactly what i was looking for, thanks alot for your posts!



    NavicLand
    http://www.angelfire.com/geek/navicland/index.html

    HeavenWare Solutions
    http://www.angelfire.com/biz7/joltware/heavenware/index.html

  • PetrusPetrus Member Posts: 10
    : : : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:31[/red][/b][hr]
    : : : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:14[/red][/b][hr]
    : : : : What would I need to know about programs written and compiled with C/C++ to process them on a ASM level. Eg. how does the Windows kernel handle a C/C++ program? How would a UNIX kernel handle and run a C/C++ program? Mostly stuff like inital memory values, disassembly of C/C++ compiled code and what happens when a C/C++ program is finished running?
    : : : : NavicLand
    : : : : http://www.angelfire.com/geek/navicland/index.html
    : : : :
    : : : : HeavenWare Solutions
    : : : : http://www.angelfire.com/biz7/joltware/heavenware/index.html
    : : : :
    : : : [blue]The compiled program (EXE or DLL) is a pure ASM. Every system has a compiler associated with it. You can't run the EXE compiled in Windows under UNIX. Somehow, I do not get what are you asking?.. When you talk about completed program - there is no C/C++. C/C++ is just a method to convert your ideas into the binary code (ASM) which can be ran on a system where you compile it.[/blue]
    : : :
    : : :
    : : :
    : : :
    : : :
    : : I think what you are looking for is the Program Segment Prefix (PSP) in DOS and its equivalent in Windows and Unix.
    : :
    : : In DOS, all exe are prefixed with the PSP which tells the system a bunch of things as far as running the exe itself. The PSP is not part of your source code, but [red]added by the compiler[/red] given that the compiler knows that the target exe is a DOS exe. Now I believe if your compiler's target is different OS, it would do (add?) different "PSP".
    : :
    : : For the DOS PSP, go to the web, look for "program segment prefix".
    : :
    : : Hope this helps.
    : :
    : :
    : [blue]PSP is added by the DOS program loader.[/blue]
    :

    Guru, Do you know what's the 512 bytes of extra stuff at the beginning of the .exe file?

    Thanks,

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [b][red]This message was edited by AsmGuru62 at 2002-8-19 13:55:40[/red][/b][hr]
    : : : : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:31[/red][/b][hr]
    : : : : [b][red]This message was edited by AsmGuru62 at 2002-8-14 14:31:14[/red][/b][hr]
    : : : : : What would I need to know about programs written and compiled with C/C++ to process them on a ASM level. Eg. how does the Windows kernel handle a C/C++ program? How would a UNIX kernel handle and run a C/C++ program? Mostly stuff like inital memory values, disassembly of C/C++ compiled code and what happens when a C/C++ program is finished running?
    : : : : : NavicLand
    : : : : : http://www.angelfire.com/geek/navicland/index.html
    : : : : :
    : : : : : HeavenWare Solutions
    : : : : : http://www.angelfire.com/biz7/joltware/heavenware/index.html
    : : : : :
    : : : : [blue]The compiled program (EXE or DLL) is a pure ASM. Every system has a compiler associated with it. You can't run the EXE compiled in Windows under UNIX. Somehow, I do not get what are you asking?.. When you talk about completed program - there is no C/C++. C/C++ is just a method to convert your ideas into the binary code (ASM) which can be ran on a system where you compile it.[/blue]
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : : I think what you are looking for is the Program Segment Prefix (PSP) in DOS and its equivalent in Windows and Unix.
    : : :
    : : : In DOS, all exe are prefixed with the PSP which tells the system a bunch of things as far as running the exe itself. The PSP is not part of your source code, but [red]added by the compiler[/red] given that the compiler knows that the target exe is a DOS exe. Now I believe if your compiler's target is different OS, it would do (add?) different "PSP".
    : : :
    : : : For the DOS PSP, go to the web, look for "program segment prefix".
    : : :
    : : : Hope this helps.
    : : :
    : : :
    : : [blue]PSP is added by the DOS program loader.[/blue]
    : :
    :
    : Guru, Do you know what's the 512 bytes of extra stuff at the beginning of the .exe file?
    :
    : Thanks,
    :
    :
    [blue]EXE header usually contains a relocation table which is set up by LINKER. The system needs to know where the file will be loaded and 'fix' the memory locations according to starting address. That is what relocation table is for. It contains relative offsets where to fix the values from relative to real ones. Maybe 512 is just an aligned value. I am sure if you have a huge program with a lot of relocation points it should be more than 512 bytes.

    Anyway, check out the 'www.wotsit.org' for file format info...[/blue]


  • Andre YoungAndre Young USAMember Posts: 0

    _________ [ http://forcoder.org ] free video tutorials and ebooks about / Python, Objective-C, Perl, Scratch, Ruby, MATLAB, R, Visual Basic, C#, Java, C++, PL/SQL, JavaScript, Assembly, Go, Swift, Delphi, PHP, Visual Basic .NET, C COBOL, D, Clojure, VBScript, Hack, Dart, LabVIEW, Fortran, Crystal, FoxPro, Erlang, F#, Prolog, Transact-SQL, Apex, Scala, Lisp, Lua, ABAP, Logo, SAS, Kotlin, Scheme, Ada, ML, Alice, Bash, Rust, Julia, Awk / ________

Sign In or Register to comment.