Note that there are some explanatory texts on larger screens.

plurals
  1. POYet another 'undefined reference to _main'
    primarykey
    data
    text
    <p>I've been attempting to convert the bulk of my current OS project from x86 Assembly over to C and assemble with NASM and compile with MinGW. When linking, I get these errors:</p> <pre><code>ld: warning: cannot find entry symbol start; defaulting to 00100000 o\main.o:main.c:(.text+0x7): undefined reference to `_main' </code></pre> <p>Here's the script I'm compilng, assembling and linking with:</p> <pre><code>gcc -c main.c -o o\main.o -fno-leading-underscore nasm boot.asm -o o\boot.o -fcoff ld -o bin\kernel.bin o\boot.o o\main.o -Tlink.ld </code></pre> <p>...and my linker script is the following:</p> <pre><code>ENTRY(start) SECTIONS { .text 0x100000 : { code = .; _code = .; __code = .; *(.text) . = ALIGN(4096); } .data : { data = .; _data = .; __data = .; *(.data) *(.rodata) . = ALIGN(4096); } .bss : { bss = .; _bss = .; __bss = .; *(.bss) . = ALIGN(4096); } end = .; _end = .; __end = .; } </code></pre> <p>When I use nm on main.o, it says that there is something with the symbol '__main', but I've declared it like this:</p> <pre><code>int main() { return 0xDEADBABA; } </code></pre> <p>Here's boot.asm:</p> <pre><code>MBOOT_PAGE_ALIGN equ 1&lt;&lt;0 ; Load kernel and modules on a page boundary MBOOT_MEM_INFO equ 1&lt;&lt;1 ; Provide your kernel with memory info MBOOT_HEADER_MAGIC equ 0x1BADB002 ; Multiboot Magic value MBOOT_HEADER_FLAGS equ MBOOT_PAGE_ALIGN | MBOOT_MEM_INFO MBOOT_CHECKSUM equ -(MBOOT_HEADER_MAGIC + MBOOT_HEADER_FLAGS) [bits 32] [global mboot] [extern code] [extern bss] [extern end] mboot: dd MBOOT_HEADER_MAGIC dd MBOOT_HEADER_FLAGS dd MBOOT_CHECKSUM dd mboot dd code dd bss dd end dd start [extern main] [global start] start: push ebx cli call main jmp $ </code></pre> <p>I suspect that this problem I'm having is because of Microsoft being their usual, stupid selves and requiring some sort of underscore prefix or something. Can anyone please provide a solution to this problem? Cheers.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload