I spent the last three days reading through all the archives.
And I have no clue what I am doing wrong.  I only started down
this road because of some of the other posters.  I figured I
would give assembly a shot.

I read Assembly Step by Step, which is really geared toward
DOS and linux, but it's a pretty good overview.  

>From what I have read of the history, openBSD went from aout
to ELF around 3.0 with the addition of some extra information.

I am guessing that my problem is related to doing something
wrong with the amd64.  But I'm not sure what to read next.
I did go through the first hundred pages of the amd programmers
guide on the amd website.

I am assembling and linking:

as -o test1.o test1.s
ld -o test1 test1.o

file type reads as:

test1: ELF 64-bit LSB executable, AMD64, version 1, for OpenBSD, statically
linked, not stripped

so it's set as OpenBSD.

And readelf gives me:

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x400218
  Start of program headers:          64 (bytes into file)
  Start of section headers:          664 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         4
  Size of section headers:           64 (bytes)
  Number of section headers:         10
  Section header string table index: 7

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000000400218  00000218
       0000000000000015  0000000000000000  AX       0     0     4
  [ 2] .data             PROGBITS         0000000000600230  00000230
       000000000000000d  0000000000000000  WA       0     0     4
  [ 3] .gotpad0          PROGBITS         000000000070023d  00000240
       0000000000000000  0000000000000000   W       0     0     1
  [ 4] .gotpad1          PROGBITS         000000000070023d  00000240
       0000000000000000  0000000000000000   W       0     0     1
  [ 5] .bss              NOBITS           0000000000800240  00000240
       0000000000000000  0000000000000000  WA       0     0     4
  [ 6] .note.openbsd.ide NOTE             0000000000400200  00000200
       0000000000000018  0000000000000000   A       0     0     4
  [ 7] .shstrtab         STRTAB           0000000000000000  00000240
       0000000000000052  0000000000000000           0     0     1
  [ 8] .symtab           SYMTAB           0000000000000000  00000518
       00000000000001b0  0000000000000018           9     c     8
  [ 9] .strtab           STRTAB           0000000000000000  000006c8
       000000000000003e  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x000000000000022d 0x000000000000022d  R E    100000
  LOAD           0x0000000000000230 0x0000000000600230 0x0000000000600230
                 0x000000000000000d 0x000000000000000d  RW     100000
  LOAD           0x0000000000000240 0x0000000000800240 0x0000000000800240
                 0x0000000000000000 0x0000000000000000  RW     100000
  NOTE           0x0000000000000200 0x0000000000400200 0x0000000000400200
                 0x0000000000000018 0x0000000000000018  R      4

 Section to Segment mapping:
  Segment Sections...
   00     .text .note.openbsd.ident
   01     .data
   02
   03     .note.openbsd.ident

There is no dynamic segment in this file.

There are no relocations in this file.

Here is my current code:

.section ".note.openbsd.ident", "a"
        .p2align 2
        .long   8
        .long   4
        .long   1
        .ascii "OpenBSD\0"
        .long   0
        .p2align 2


.section .data

        msg: .asciz "hello world\n"
        len = . - msg - 1

.section .text                   

.global _start          

_start:
    push $len
    push $msg
    push $1
    movb $4, %al
    push %rax
    int  $0x80

    push $0
    movb $1, %al
    push %rax
    int  $0x80

Any links or man pages to read would be helpful?  I have all ready info as, and
it's pretty old, but it's still useful.

When I type in test1, the program appears to just exit, but nothing is printed
to STDOUT.

Thanks,

Brian


                
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 

Reply via email to