Thanks for your help! I'm able to create the .o objects and objdump their contents, but I don't know how to look in the dumps to find entry points.

C:\> gcc -c scriptedmain.c scriptedmain.h C:\> gcc -c test.c scriptedmain.c scriptedmain.h C:\> objdump -x scriptedmain.o scriptedmain.o: file format pe-i386 scriptedmain.o architecture: i386, flags 0x00000039: HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS start address 0x00000000 Characteristics 0x104 line numbers stripped 32 bit words Time/Date Wed Dec 31 19:00:00 1969 Magic 0000 MajorLinkerVersion 0 MinorLinkerVersion 0 SizeOfCode 00000000 SizeOfInitializedData 00000000 SizeOfUninitializedData 00000000 AddressOfEntryPoint 00000000 BaseOfCode 00000000 BaseOfData 00000000 ImageBase 00000000 SectionAlignment 00000000 FileAlignment 00000000 MajorOSystemVersion 0 MinorOSystemVersion 0 MajorImageVersion 0 MinorImageVersion 0 MajorSubsystemVersion 0 MinorSubsystemVersion 0 Win32Version 00000000 SizeOfImage 00000000 SizeOfHeaders 00000000 CheckSum 00000000 Subsystem 00000000 (unspecified) DllCharacteristics 00000000 SizeOfStackReserve 00000000 SizeOfStackCommit 00000000 SizeOfHeapReserve 00000000 SizeOfHeapCommit 00000000 LoaderFlags 00000000 NumberOfRvaAndSizes 00000000 The Data Directory Entry 0 00000000 00000000 Export Directory [.edata (or where ever we f +ound it)] Entry 1 00000000 00000000 Import Directory [parts of .idata] Entry 2 00000000 00000000 Resource Directory [.rsrc] Entry 3 00000000 00000000 Exception Directory [.pdata] Entry 4 00000000 00000000 Security Directory Entry 5 00000000 00000000 Base Relocation Directory [.reloc] Entry 6 00000000 00000000 Debug Directory Entry 7 00000000 00000000 Description Directory Entry 8 00000000 00000000 Special Directory Entry 9 00000000 00000000 Thread Storage Directory [.tls] Entry a 00000000 00000000 Load Configuration Directory Entry b 00000000 00000000 Bound Import Directory Entry c 00000000 00000000 Import Address Table Directory Entry d 00000000 00000000 Delay Import Directory Entry e 00000000 00000000 CLR Runtime Header Entry f 00000000 00000000 Reserved Sections: Idx Name Size VMA LMA File off Algn 0 .text 00000034 00000000 00000000 000000b4 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 1 .data 00000000 00000000 00000000 00000000 2**2 ALLOC, LOAD, DATA 2 .bss 00000000 00000000 00000000 00000000 2**2 ALLOC 3 .rdata 00000024 00000000 00000000 000000e8 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA SYMBOL TABLE: [ 0](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000000 scriptedmain +.c File [ 2](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 1) 0x00000000 _meaning_of_ +life AUX tagndx 0 ttlsiz 0x0 lnnos 0 next 0 [ 4](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .text AUX scnlen 0x34 nreloc 3 nlnno 0 [ 6](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .data AUX scnlen 0x0 nreloc 0 nlnno 0 [ 8](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss AUX scnlen 0x0 nreloc 0 nlnno 0 [ 10](sec 4)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .rdata AUX scnlen 0x21 nreloc 0 nlnno 0 [ 12](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000a .weak._main. +_meaning_of_life [ 13](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 ___main [ 14](sec 0)(fl 0x00)(ty 20)(scl 105) (nx 1) 0x00000000 _main AUX lnno 1 size 0x0 tagndx 12 [ 16](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _printf RELOCATION RECORDS FOR [.text]: OFFSET TYPE VALUE 00000014 DISP32 ___main 00000024 dir32 .rdata 00000029 DISP32 _printf C:\> objdump -x test.o test.o: file format pe-i386 test.o architecture: i386, flags 0x00000039: HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS start address 0x00000000 Characteristics 0x104 line numbers stripped 32 bit words Time/Date Wed Dec 31 19:00:00 1969 Magic 0000 MajorLinkerVersion 0 MinorLinkerVersion 0 SizeOfCode 00000000 SizeOfInitializedData 00000000 SizeOfUninitializedData 00000000 AddressOfEntryPoint 00000000 BaseOfCode 00000000 BaseOfData 00000000 ImageBase 00000000 SectionAlignment 00000000 FileAlignment 00000000 MajorOSystemVersion 0 MinorOSystemVersion 0 MajorImageVersion 0 MinorImageVersion 0 MajorSubsystemVersion 0 MinorSubsystemVersion 0 Win32Version 00000000 SizeOfImage 00000000 SizeOfHeaders 00000000 CheckSum 00000000 Subsystem 00000000 (unspecified) DllCharacteristics 00000000 SizeOfStackReserve 00000000 SizeOfStackCommit 00000000 SizeOfHeapReserve 00000000 SizeOfHeapCommit 00000000 LoaderFlags 00000000 NumberOfRvaAndSizes 00000000 The Data Directory Entry 0 00000000 00000000 Export Directory [.edata (or where ever we f +ound it)] Entry 1 00000000 00000000 Import Directory [parts of .idata] Entry 2 00000000 00000000 Resource Directory [.rsrc] Entry 3 00000000 00000000 Exception Directory [.pdata] Entry 4 00000000 00000000 Security Directory Entry 5 00000000 00000000 Base Relocation Directory [.reloc] Entry 6 00000000 00000000 Debug Directory Entry 7 00000000 00000000 Description Directory Entry 8 00000000 00000000 Special Directory Entry 9 00000000 00000000 Thread Storage Directory [.tls] Entry a 00000000 00000000 Load Configuration Directory Entry b 00000000 00000000 Bound Import Directory Entry c 00000000 00000000 Import Address Table Directory Entry d 00000000 00000000 Delay Import Directory Entry e 00000000 00000000 CLR Runtime Header Entry f 00000000 00000000 Reserved Sections: Idx Name Size VMA LMA File off Algn 0 .text 0000002c 00000000 00000000 000000b4 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 1 .data 00000000 00000000 00000000 00000000 2**2 ALLOC, LOAD, DATA 2 .bss 00000000 00000000 00000000 00000000 2**2 ALLOC 3 .rdata 00000024 00000000 00000000 000000e0 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA SYMBOL TABLE: [ 0](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000000 test.c File [ 2](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _main [ 3](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .text AUX scnlen 0x2a nreloc 4 nlnno 0 [ 5](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .data AUX scnlen 0x0 nreloc 0 nlnno 0 [ 7](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss AUX scnlen 0x0 nreloc 0 nlnno 0 [ 9](sec 4)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .rdata AUX scnlen 0x21 nreloc 0 nlnno 0 [ 11](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 1) 0x00000000 ___main AUX tagndx 0 ttlsiz 0x0 lnnos 0 next 0 [ 13](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _meaning_of_ +life [ 14](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _printf RELOCATION RECORDS FOR [.text]: OFFSET TYPE VALUE 0000000a DISP32 ___main 0000000f DISP32 _meaning_of_life 0000001a dir32 .rdata 0000001f DISP32 _printf

If I'm reading these correctly, both seem to contain the entry points _main and __main. At least the offsets differ, but compiling scriptedmain by referring to the entry point offset doesn't work.

C:\Users\andrew\Desktop\src\scriptedmain\c>gcc -o scriptedmain -e00000 +014 scriptedmain.c scriptedmain.h c:/strawberry/c/bin/../lib/gcc/i686-w64-mingw32/4.4.3/../../../../i686 +-w64-mingw32/lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o): In functi +on `main': /opt/W64_156151-src.32/build-crt/../mingw-w64-crt/crt/crt0_c.c:18: und +efined reference to `WinMain@16' collect2: ld returned 1 exit status

In reply to Re^4: (OT) How can I do unless(caller) { main; } in C using GCC in Windows? by Anonymous Monk
in thread (OT) How can I do unless(caller) { main; } in C using GCC in Windows? by mcandre

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.