Page 1 of 2

yasm cross-compiler

Posted: Mon Apr 02, 2007 9:26 am
by ehird
I build yasm with ./configure --build=i586-elf --prefix=/usr/local/cross

Now when I compile with it i get a bus error:

Code: Select all

/usr/local/cross/bin/yasm kernel/start.asm -o kernel/start.o
sh: line 1:  8135 Bus error               $AS $stem.asm -o $stem.o
mk: /usr/local/cross/bin/yasm kernel/start.asm -o kernel/start.o  : exit status=exit(138)
What did I do wrong? :)

Posted: Mon Apr 02, 2007 10:31 am
by Brynet-Inc
Hmm.. That's a strange error.. haven't seen that one.. are you using a Makefile? Does it compile when manually evoked? Code Syntax issue?

Posted: Mon Apr 02, 2007 10:33 am
by ~

Posted: Mon Apr 02, 2007 10:43 am
by ehird
Brynet-Inc wrote:Hmm.. That's a strange error.. haven't seen that one.. are you using a Makefile? Does it compile when manually evoked? Code Syntax issue?
Bus error is what OS X likes to call segfaults.

It's a mkfile, mk is a plan9 tool similar to make but better. there's a port to unix-based systems.

It doesn't compile manually when evoked.

Syntax shouldn't cause segfaults ;)

Posted: Mon Apr 02, 2007 10:46 am
by ~
That looked like trying to compile something "noncompilable" under MacOSX :?

Posted: Mon Apr 02, 2007 10:50 am
by ehird
It's a cross-compiler though - it shouldn't care about OS X. Here's the code, from bkerndev

Code: Select all

[BITS 32]
global start
start:
	mov esp, sys_stack
	jmp stublet

ALIGN 4
mboot:
	MULTIBOOK_PAGE_ALIGN equ 1<<0
	MULTIBOOT_MEMORY_INFO equ 1<<1
	MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
	MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
	MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC +
	    MULTIBOOT_HEADER_FLAGS)
	EXTERN code, bss, end
	dd MULTIBOOT_HEADER_MAGIC
	dd MULTIBOOT_HEADER_FLAGS
	dd MULTIBOOT_CHECKSUM

stublet:
	jmp $

SECTION .bss
	resb 8192
sys_stack:

Posted: Mon Apr 02, 2007 10:54 am
by Brynet-Inc
ehird wrote:Bus error is what OS X likes to call segfaults.
Are you trying to run an ELF binary on your Mac then?..
ehird wrote:./configure --build=i586-elf ...
Or are you building the yasm binary for the Mac on a Linux system? :?

OSX uses the Mach-O File Format not ELF right?..

Posted: Mon Apr 02, 2007 10:58 am
by ehird
i586-elf is what my gcc/binutils are, and I've compiled GAS and C code with them just fine... and it works as a kernel...

So... I chose the same for yasm (as bkerndev uses intel syntax not gas' at/t... and I don't want to bother myself with the intel-syntax instructions for gas). I'm assembling here, not running the binary... you know... building the kernel...

Edit: and --build specifies "What formats this yasm will build". So that's saying "build a mac/Mach-O yasm that assembles to ELF"

Edit: Here's the line of yasm code that fails...

Code: Select all

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000006
yasm_intnum_copy (intn=0x2) at libyasm/intnum.c:351
351	    switch (intn->type) {

Posted: Mon Apr 02, 2007 11:01 am
by Brynet-Inc
I don't think so.. yasm output defaults to "plain-binary"..

I'm pretty sure --build= will not specify the output format yasm will compile.. :?

Posted: Mon Apr 02, 2007 11:04 am
by ehird

Code: Select all

  --build=BUILD     configure for building on BUILD [guessed]
Oh, yeah?

Posted: Mon Apr 02, 2007 11:06 am
by Combuster
YASM is written in C. To compile it you simply have to run
./configure
make
make install
you don't need to specify specific configure options if you dont know what you are doing. YASM as i have it automatically contains all targets in binary - you just have to select at run-time which one you want to use.

Posted: Mon Apr 02, 2007 11:12 am
by ehird
Yes, but I had the same problem when I used a normal yasm with -f elf, so I tried building a cross-assembler.

Posted: Mon Apr 02, 2007 11:15 am
by Brynet-Inc
ehird wrote:Yes, but I had the same problem when I used a normal yasm with -f elf, so I tried building a cross-assembler.
I think ehird is confused.. :wink:

Posted: Mon Apr 02, 2007 11:16 am
by ehird
Brynet-Inc wrote:
ehird wrote:Yes, but I had the same problem when I used a normal yasm with -f elf, so I tried building a cross-assembler.
I think ehird is confused.. :wink:
I just want to get this to assemble :P

Posted: Mon Apr 02, 2007 11:17 am
by ~
In those cases I always prefer to start with only one version of binaries to have my work done and then advance eventually in additional features and support capabilities...