yasm cross-compiler

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
ehird
Member
Member
Posts: 214
Joined: Thu Mar 15, 2007 8:48 am

yasm cross-compiler

Post 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? :)
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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?
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Post by ~ »

ehird
Member
Member
Posts: 214
Joined: Thu Mar 15, 2007 8:48 am

Post 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 ;)
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Post by ~ »

That looked like trying to compile something "noncompilable" under MacOSX :?
ehird
Member
Member
Posts: 214
Joined: Thu Mar 15, 2007 8:48 am

Post 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:
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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?..
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
ehird
Member
Member
Posts: 214
Joined: Thu Mar 15, 2007 8:48 am

Post 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) {
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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.. :?
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
ehird
Member
Member
Posts: 214
Joined: Thu Mar 15, 2007 8:48 am

Post by ehird »

Code: Select all

  --build=BUILD     configure for building on BUILD [guessed]
Oh, yeah?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
ehird
Member
Member
Posts: 214
Joined: Thu Mar 15, 2007 8:48 am

Post 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.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
ehird
Member
Member
Posts: 214
Joined: Thu Mar 15, 2007 8:48 am

Post 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
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Post 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...
Post Reply