From: Evenbit on
On Apr 13, 12:12 pm, Frank Kotler <fbkot...(a)verizon.net> wrote:
>
> (We *can* do dynamic
> linking! Have you looked at Stephen Pelc's example at all?)

Interesting paper! NEXT STEP: Use this method to access the GObject
system and you'll be creating GUI apps without a linker! :)

http://en.wikipedia.org/wiki/GObject
http://library.gnome.org/devel/gobject/unstable/

Nathan.
From: Herbert Kleebauer on
Frank Kotler wrote:
> Herbert Kleebauer wrote:


> >> (We *can* do dynamic
> >> linking! Have you looked at Stephen Pelc's example at all?)

Searched in the my saved documentation. Yes, it was his article I read.

> > I have read one article about doing it manually by using a trivial
> > hash table, but I think I would prefer to modify the assembler
> > so it would generate a real hash table.
>
> Okay. What's wrong with the "trivial" one? I'll have to look at


It's like your assembler doesn't for some reason assemble the instruction
"inc edx". I don't have any problem to use "db 0x42" instead, the generated
binary is the same (this is like including the elf header with "db" statements
in the assembler source). But I wouldn't like to replace any "inc edx" by the
sequence:

xchg eax,edx
inc eax
xchg eax,edx

just because my assembler doesn't support the "inc edx" instruction.
I think then it is better to modify the assembler so it will support
the "inc edx" instruction and the same is true for the hash table for
dynamic linking. I understand that this is a problem for the wide spread
NASM. But in my case it doesn't matter whether in include the additional
code in the source code of the assembly program or in the C source of
the assembler. I also don't need macro support, because when ever I need
something like a macro, I can implement it in the assembler instead in
the assembly source code. As Betov included the assembly source in the
binary, I (logically) include the in C written assembler source in the
assembly source a therefore have the full power of the C compiler available.


> Here's one more way to fix a broken executable. More complicated than it
> needs to be - I was inspired by Almas! :) I don't know if it's even
> "right". Works on the few I've tried it on... I'll have to boot to 12.0
> and make a few more. Or, hmmm, what if I copied over the missing
> libraries...
>
> Best,
> Frank
>
> ; fetches byte 48h, rounds up to a multiple of 4
> ; and stuffs it into byte 58h

I don't think this will solve the problem, there are still 3 bytes missing (from
the "align 4") in the output file and therefore the data segment starts at an odd
file address. Try it with a program which prints an initialized variable.

The correct calculation would be:

even 4
@=(@+4095)/4096*4096+(@@\4096)
data_offset=@@
data_addr:

But it does:

@=(@+3)/4*4
@@1=(@@+3)/4*4

@=(@+4095)/4096*4096+(@@1\4096)
data_offset=@@
data_addr:
From: Herbert Kleebauer on
Frank Kotler wrote:

> Okay. What's wrong with the "trivial" one? I'll have to look at
> Stephen's code again

Maybe this is useful:

Here a complete disassembly of the following C program I made two years ago.

------------------------------------------------------------------------------

char uninit_global_char, init_global_char=1;
int uninit_global_int, init_global_int=2;
main()
{char uninit_local_char, init_local_char=3;
int uninit_local_int, init_local_int=4;
uninit_local_char = init_global_char;
uninit_local_int = init_global_int;
uninit_global_char= init_local_char;
uninit_global_int = init_local_int;

printf("hello world %d %d %d %d %d %d %d %d\n",
uninit_global_char,
init_global_char,
uninit_global_int,
init_global_int,
uninit_local_char,
init_local_char,
uninit_local_int,
init_local_int);
}


------------------------------------------------------------------------------


nop=$90
seg32
@=$08048000

;=============================================================================
;=== Start of Segment 2 ===
;=============================================================================

SEGM02_type=1 ; PT_LOAD Loadable segment
SEGM02_flags=5 ; PF_R + PF_X (1: execute 2: write 4:read)
SEGM02_align=4096
even 4
@=(@+SEGM02_align-1)/SEGM02_align*SEGM02_align+(@@\SEGM02_align)
SEGM02_offset=@@
SEGM02_vaddr:
SEGM02_paddr:

;*****************************************************************************
;*** Start of ELF HEADER ***
;*****************************************************************************

EI_NIDENT=16
; e_ident[EI_NIDENT]
dc.b $7f,"ELF" ; EI_MAG[0:3] File identification
dc.b 1 ; EI_CLASS ELFCASS32 32-bit objects
dc.b 1 ; EI_DATA ELFDATA2LSB 2's comp. little endian
dc.b 1 ; EI_VERSION EV_CURRENT
blk.b EI_NIDENT-@@,0 ; EI_PAD

dc.w 2 ; e_type ET_EXEC Executable file
dc.w 3 ; e_machine EM_386 Intel386
dc.l 1 ; e_version EV_CURRENT Current version
dc.l start ; e_entry Virtal address of starting point
dc.l e_phoff ; e_phoff Offset to program header table
dc.l e_shoff ; e_shoff Offset to section header table
dc.l 0 ; e_flags Processor-specific flags
dc.w e_ehsize ; e_ehsize Size of ELF header
dc.w e_phentsize ; e_phentsize Size of a program header table entry
dc.w e_phnum ; e_phnum Number of entries in program header table
dc.w e_shentsize ; e_shentsize Size of a section header table entry
dc.w e_shnum ; e_shnum Number of entries in section header table
dc.w e_shstrndx ; e_shstrndx Table index for section name string table

e_ehsize=@@

;*****************************************************************************
;*** End of ELF HEADER ***
;*****************************************************************************


;*****************************************************************************
;*** Start of Program header table ***
;*****************************************************************************

e_phoff=@@

;=============================================================================
;=== Start of Segment 0 ===
;=============================================================================

SEGM00_type=6 ; PT_PHDR Program header table
SEGM00_flags=5 ; PF_R + PF_X (1: execute 2: write 4:read)
SEGM00_align=4
even SEGM00_align ; oder "even 4" ??????????
SEGM00_offset=@@
SEGM00_vaddr:
SEGM00_paddr:

; Segment 0 PT_PHDR Program header table
dc.l SEGM00_type ; p_type
dc.l SEGM00_offset ; p_offset
dc.l SEGM00_vaddr ; p_vaddr
dc.l SEGM00_paddr ; p_paddr
dc.l SEGM00_filez ; p_filez
dc.l SEGM00_memsz ; p_memsz
dc.l SEGM00_flags ; P_flags
dc.l SEGM00_align ; p_align

e_phentsize=@@-e_phoff

; Segment 1 PT_INTERP Path name to interpreter
dc.l SEGM01_type ; p_type
dc.l SEGM01_offset ; p_offset
dc.l SEGM01_vaddr ; p_vaddr
dc.l SEGM01_paddr ; p_paddr
dc.l SEGM01_filez ; p_filez
dc.l SEGM01_memsz ; p_memsz
dc.l SEGM01_flags ; P_flags
dc.l SEGM01_align ; p_align

; Segment 2 ; PT_LOAD Loadable segment
dc.l SEGM02_type ; p_type
dc.l SEGM02_offset ; p_offset
dc.l SEGM02_vaddr ; p_vaddr
dc.l SEGM02_paddr ; p_paddr
dc.l SEGM02_filez ; p_filez
dc.l SEGM02_memsz ; p_memsz
dc.l SEGM02_flags ; P_flags
dc.l SEGM02_align ; p_align

; Segment 3 ; PT_LOAD Loadable segment
dc.l SEGM03_type ; p_type
dc.l SEGM03_offset ; p_offset
dc.l SEGM03_vaddr ; p_vaddr
dc.l SEGM03_paddr ; p_paddr
dc.l SEGM03_filez ; p_filez
dc.l SEGM03_memsz ; p_memsz
dc.l SEGM03_flags ; P_flags
dc.l SEGM03_align ; p_align

; Segment 4 ; PT_DYNAMIC Dynamic linking
dc.l SEGM04_type ; p_type
dc.l SEGM04_offset ; p_offset
dc.l SEGM04_vaddr ; p_vaddr
dc.l SEGM04_paddr ; p_paddr
dc.l SEGM04_filez ; p_filez
dc.l SEGM04_memsz ; p_memsz
dc.l SEGM04_flags ; P_flags
dc.l SEGM04_align ; p_align

; Segment 5 ; PT_NOTE Auxilary information
dc.l SEGM05_type ; p_type
dc.l SEGM05_offset ; p_offset
dc.l SEGM05_vaddr ; p_vaddr
dc.l SEGM05_paddr ; p_paddr
dc.l SEGM05_filez ; p_filez
dc.l SEGM05_memsz ; p_memsz
dc.l SEGM05_flags ; P_flags
dc.l SEGM05_align ; p_align

; Segment 6 ; ??????Stack?????
dc.l $6474e551 ; p_type ; ??????
dc.l $00000000 ; p_offset
dc.l $00000000 ; p_vaddr
dc.l $00000000 ; p_paddr
dc.l $00000000 ; p_filez
dc.l $00000000 ; p_memsz
dc.l $00000006 ; P_flags
dc.l $00000004 ; p_align

SEGM00_filez=@@-SEGM00_offset
SEGM00_memsz=@-SEGM00_vaddr

;=============================================================================
;=== End of Segment 0 ===
;=============================================================================

e_phnum=(@@-e_phoff)/e_phentsize

;*****************************************************************************
;*** End of Program header table ***
;*****************************************************************************


;=============================================================================
;=== Start of Segment 1 ===
;=============================================================================
SEGM01_type=3 ; PT_INTERP Path name to interpreter
SEGM01_flags=4 ; PF_R (1: execute 2: write 4:read)
SEGM01_align=1
even SEGM01_align ; oder "even 4" ??????????
SEGM01_offset=@@
SEGM01_vaddr:
SEGM01_paddr:

;-----------------------------------------------------------------------------
;--- Start of Section 1 ---
;-----------------------------------------------------------------------------
SECT01_name=sect_name02 ; ".interp"
SECT01_type=1 ; SHT_PROGBITS
SECT01_flags=2 ; SHF_ALLOC
SECT01_link=0
SECT01_info=0
SECT01_addralign=1
SECT01_entsize=0
even SECT01_addralign
SECT01_offset=@@
SECT01_addr:

dc.b "/lib/ld-linux.so.2",0

SECT01_size=@@-SECT01_offset

;-----------------------------------------------------------------------------
;--- End of Section 1 ---
;-----------------------------------------------------------------------------

SEGM01_filez=@@-SEGM01_offset
SEGM01_memsz=@-SEGM01_vaddr

;=============================================================================
;=== End of Segment 1 ===
;=============================================================================


;=============================================================================
;=== Start of Segment 5 ===
;=============================================================================
SEGM05_type=4 ; PT_NOTE Auxilary information
SEGM05_flags=4 ; PF_R (1: execute 2: write 4:read)
SEGM05_align=4
even SEGM05_align ; oder "even 4" ??????????
SEGM05_offset=@@
SEGM05_vaddr:
SEGM05_paddr:

;-----------------------------------------------------------------------------
;--- Start of Section 2 ---
;-----------------------------------------------------------------------------
SECT02_name=sect_name03 ; ".note.ABI-tag"
SECT02_type=7 ; SHT_NOTE
SECT02_flags=2 ; SHF_ALLOC
SECT02_link=0
SECT02_info=0
SECT02_addralign=4
SECT02_entsize=0
even SECT02_addralign
SECT02_offset=@@
SECT02_addr:

dc.l _name_l ; namesz
dc.l _desc_l ; descsz
dc.l 1 ; type

_name: dc.b "GNU",0
_name_l=@-_name
_desc: dc.l 0,2,2,0
_desc_l=@-_desc

SECT02_size=@@-SECT02_offset
;-----------------------------------------------------------------------------
;--- End of Section 2 ---
;-----------------------------------------------------------------------------

SEGM05_filez=@@-SEGM05_offset
SEGM05_memsz=@-SEGM05_vaddr

;=============================================================================
;=== End of Segment 5 ===
;=============================================================================



;-----------------------------------------------------------------------------
;--- Start of Section 3 ---
;-----------------------------------------------------------------------------
SECT03_name=sect_name04 ; ".hash"
SECT03_type=5 ; SHT_HASH
SECT03_flags=2 ; SHF_ALLOC
SECT03_link=4 ; this hash is for symbol tabel in SECT04
SECT03_info=0
SECT03_addralign=4
SECT03_entsize=4
even SECT03_addralign
SECT03_offset=@@
SECT03_addr:

DT_HASH:
dc.l 3 ; nbucket
dc.l 6 ; nchain

dc.l 5 ; bucket[0]
dc.l 1 ; bucket[1]
dc.l 3 ; bucket[2]


dc.l 0 ; chain[0]
dc.l 0 ; chain[1]
dc.l 0 ; chain[2]
dc.l 2 ; chain[3]
dc.l 0 ; chain[4]
dc.l 4 ; chain[5]


SECT03_size=@@-SECT03_offset
;-----------------------------------------------------------------------------
;--- End of Section 3 ---
;-----------------------------------------------------------------------------


;-----------------------------------------------------------------------------
;--- Start of Section 4 ---
;-----------------------------------------------------------------------------
SECT04_name=sect_name05 ; ".dynsym"
SECT04_type=11 ; SHT_DYNSYM
SECT04_flags=2 ; SHF_ALLOC
SECT04_link=5 ; associated string table ->SECT05
SECT04_info=1 ; 1 + 0 : no local symbols?????
SECT04_addralign=4
SECT04_entsize=16
even SECT04_addralign
SECT04_offset=@@
SECT04_addr:

DT_SYMTAB:
dc.l 0 ; st_name
dc.l 0 ; st_value
dc.l 0 ; st_size
dc.b 0 ; st_info
dc.b 0 ; st_other
dc.w 0 ; st_shndx
DT_SYMENT=@-DT_SYMTAB

sym_tab_libc_start_main=(@-DT_SYMTAB)/DT_SYMENT
dc.l dyn_name06 ; st_name "__libc_start_main"
dc.l 0 ; st_value
dc.l $fa ; st_size
dc.b $12 ; st_info STB_GLOBAL + STT_FUNC
dc.b 0 ; st_other
dc.w 0 ; st_shndx

sym_tab_printf=(@-DT_SYMTAB)/DT_SYMENT
dc.l dyn_name04 ; st_name "printf"
dc.l 0 ; st_value
dc.l $39 ; st_size
dc.b $12 ; st_info STB_GLOBAL + STT_FUNC
dc.b 0 ; st_other
dc.w 0 ; st_shndx

dc.l dyn_name05 ; st_name "_IO_stdin_used"
dc.l IO_stdin_used ; st_value
dc.l 4 ; st_size
dc.b $11 ; st_info STB_GLOBAL + STT_OBJECT
dc.b 0 ; st_other
dc.w 14 ; st_shndx defined in section 14

dc.l dyn_name01 ; st_name "_Jv_RegisterClasses"
dc.l 0 ; st_value
dc.l 0 ; st_size
dc.b $20 ; st_info STB_WEAK + STT_NOTYPE
dc.b 0 ; st_other
dc.w 0 ; st_shndx

sym_tab_gmon_start=(@-DT_SYMTAB)/DT_SYMENT
dc.l dyn_name02 ; st_name __gmon_start__"
dc.l 0 ; st_value
dc.l 0 ; st_size
dc.b $20 ; st_info STB_WEAK + STT_NOTYPE
dc.b 0 ; st_other
dc.w 0 ; st_shndx

SECT04_size=@@-SECT04_offset
;-----------------------------------------------------------------------------
;--- End of Section 4 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 5 ---
;-----------------------------------------------------------------------------
SECT05_name=sect_name06 ; ".dynstr"
SECT05_type=3 ; SHT_STRTAB
SECT05_flags=2 ; SHF_ALLOC
SECT05_link=0
SECT05_info=0
SECT05_addralign=1
SECT05_entsize=0
even SECT05_addralign
SECT05_offset=@@
SECT05_addr:

DT_STRTAB:
@1=@
dyn_name00=@-@1
dc.b 0
dyn_name01=@-@1
dc.b "_Jv_RegisterClasses",0
dyn_name02=@-@1
dc.b "__gmon_start__",0

DT_NEEDED=@-DT_STRTAB
dyn_name03=@-@1
dc.b "libc.so.6",0
dyn_name04=@-@1
dc.b "printf",0
dyn_name05=@-@1
dc.b "_IO_stdin_used",0
dyn_name06=@-@1
dc.b "__libc_start_main",0
dyn_name07=@-@1
dc.b "GLIBC_2.0",0

DT_STRSZ=@-DT_STRTAB

SECT05_size=@@-SECT05_offset
;-----------------------------------------------------------------------------
;--- End of Section 5 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 6 ---
;-----------------------------------------------------------------------------
SECT06_name=sect_name07 ; ".gnu.version"
SECT06_type=$6fffffff ; ????????
SECT06_flags=2 ; SHF_ALLOC
SECT06_link=4 ; ??????????
SECT06_info=0
SECT06_addralign=2
SECT06_entsize=2
even SECT06_addralign
SECT06_offset=@@
SECT06_addr:

DT_Y: dc.l $00020000, $00010002, 0

SECT06_size=@@-SECT06_offset
;-----------------------------------------------------------------------------
;--- End of Section 6 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 7 ---
;-----------------------------------------------------------------------------
SECT07_name=sect_name08 ; ".gnu.version.r"
SECT07_type=$6ffffffe ; ?????????
SECT07_flags=2 ; SHF_ALLOC
SECT07_link=5 ; ?????????
SECT07_info=1
SECT07_addralign=4
SECT07_entsize=0
even SECT07_addralign
SECT07_offset=@@
SECT07_addr:

DT_X: dc.l $00010001, $00000024, $00000010, 0
dc.l $0d696910, $00020000, $00000056, 0

SECT07_size=@@-SECT07_offset
;-----------------------------------------------------------------------------
;--- End of Section 7 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 8 ---
;-----------------------------------------------------------------------------
SECT08_name=sect_name09 ; ".rel.dyn"
SECT08_type=9 ; SHT_REL
SECT08_flags=2 ; SHF_ALLOC
SECT08_link=4 ; associated symbole tabel -> SECT04
SECT08_info=0 ; relocation applies to no section (SECT0) ???
SECT08_addralign=4
SECT08_entsize=8
even SECT08_addralign
SECT08_offset=@@
SECT08_addr:

DT_REL:
dc.l gmon_start, (sym_tab_gmon_start<<8) + 6 ; R_386_GLOB_DAT

DT_RELENT=@-DT_REL

DT_RELSZ=@-DT_REL

SECT08_size=@@-SECT08_offset
;-----------------------------------------------------------------------------
;--- End of Section 8 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 9 ---
;-----------------------------------------------------------------------------
SECT09_name=sect_name10 ; ".rel.plt"
SECT09_type=9 ; SHT_REL
SECT09_flags=2 ; SHF_ALLOC
SECT09_link=4 ; associated symbole tabel -> SECT04
SECT09_info=11 ; relocation applies to SECT11
SECT09_addralign=4
SECT09_entsize=8
even SECT09_addralign
SECT09_offset=@@
SECT09_addr:

DT_JUMPREL:
@1=@

rel_tab_libc_start_main=@-@1
dc.l got_libc_start_main,(sym_tab_libc_start_main<<8)+7 ;R_386_JMP_SLOT

rel_tab_printf=@-@1
dc.l got_printf, (sym_tab_printf<<8)+7 ; R_386_JMP_SLOT

DT_PLTRELSZ=@-DT_JUMPREL

SECT09_size=@@-SECT09_offset
;-----------------------------------------------------------------------------
;--- End of Section 9 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 10 ---
;-----------------------------------------------------------------------------
SECT10_name=sect_name12 ; ".init"
SECT10_type=1 ; SHT_PROGBITS
SECT10_flags=6 ; SHF_ALLOC + SHF_EXECINSTR
SECT10_link=0
SECT10_info=0
SECT10_addralign=4
SECT10_entsize=0
even SECT10_addralign
SECT10_offset=@@
SECT10_addr:

DT_INIT:
init: move.l r4,-(sp)
move.l r7,r4
subq.l #8,r7
bsr.l init1
bsr.l init2
bsr.l init3
unlk.l r4
rts.l

SECT10_size=@@-SECT10_offset
;-----------------------------------------------------------------------------
;--- End of Section 10 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 11 ---
;-----------------------------------------------------------------------------
SECT11_name=sect_name11 ; ".plt"
SECT11_type=1 ; SHT_PROGBITS
SECT11_flags=6 ; SHF_ALLOC + SHF_EXECINSTR
SECT11_link=0
SECT11_info=0
SECT11_addralign=4
SECT11_entsize=4
even SECT11_addralign
SECT11_offset=@@
SECT11_addr:

bind: move.l got1,-(sp) ; identifying information for dynamic likner
jmp.l (got2) ; call dynamic linker

even 16,0

libc_start_main:
jmp.l (got_libc_start_main)
bind_libc_start_main:
move.l #rel_tab_libc_start_main,-(sp)
br.l bind


printf: jmp.l (got_printf)
bind_printf:
move.l #rel_tab_printf,-(sp) ; offset in relocation table
br.l bind ; call dynamic linker for late binding


SECT11_size=@@-SECT11_offset
;-----------------------------------------------------------------------------
;--- End of Section 11 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 12 ---
;-----------------------------------------------------------------------------
SECT12_name=sect_name13 ; ".text"
SECT12_type=1 ; SHT_PROGBITS
SECT12_flags=6 ; SHF_ALLOC + SHF_EXECINSTR
SECT12_link=0
SECT12_info=0
SECT12_addralign=16
SECT12_entsize=0
even SECT12_addralign
SECT12_offset=@@
SECT12_addr:

start: eor.l r4,r4
move.l (sp)+,r5
move.l r7,r2
andq.l #-16,r7
move.l r0,-(sp)
move.l r7,-(sp)
move.l r1,-(sp)
move.l #start1,-(sp)
move.l #start2,-(sp)
move.l r2,-(sp)
move.l r5,-(sp)
move.l #main,-(sp)
bsr.l libc_start_main
dc.b $f4 ; halt (bug in windela!)

even 4,nop
init1: move.l r4,-(sp)
move.l r7,r4
move.l r3,-(sp)
bsr.l _20

_20: move.l (sp)+,r3
add.l #$00001353,r3
move.l r0,-(sp)
move.l 20(r3),r0
tst.l r0,r0
beq.b _10
jsr.l (r0)
_10: move.l -4.b(r4){s7},r3
unlk.l r4
rts.l

even 16,nop
cleanup1:
move.l r4,-(sp)
move.l r7,r4
subq.l #8,r7
cmp.b #0,var1
beq.b _30
br.b _10
br.b _20

even 16,nop
_20: addq.l #4,r0
move.l r0,var2
jsr.l (r1)
_30: move.l var2,r0
move.l (r0),r1
tst.l r1,r1
bne.b _20
move.b #1,var1
_10: unlk.l r4
rts.l

move.l r5,r5 ; 2byte nop -> even 16
init2: move.l r4,-(sp)
move.l r7,r4
subq.l #8,r7
move.l var3,r0
tst.l r0,r0
beq.b _10
move.l #0,r0
tst.l r0,r0
beq.b _10
subq.l #12,r7
move.l #var3,-(sp)
bsr.l 0
addq.l #16,r7
nop
dc.b $8d,$b4,$26,$00,$00,$00,$00 ; lea.l 0(r5),r5
; (7byte nop) ->even 16
_10: unlk.l r4
rts.l

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
uninit_local_char = -1
init_local_char = -2
uninit_local_int = -8
init_local_int = -12

even 4,nop
main: move.l r4,-(sp)
move.l r7,r4
subq.l #24,r7
andq.l #$f0,r7
move.l #0,r0
addq.l #15,r0
addq.l #15,r0
lsr.l #4,r0
lsl.l #4,r0
sub.l r0,r7

move.b #3,init_local_char.b(r4){s7}
move.l #4,init_local_int.b(r4){s7}
move.b init_global_char,r0
move.b r0,uninit_local_char.b(r4){s7}
move.l init_global_int,r0
move.l r0,uninit_local_int.b(r4){s7}
move.b init_local_char.b(r4){s7},r0
move.b r0,unint_global_char
move.l init_local_int.b(r4){s7},r0
move.l r0,uninit_global_int
subq.l #12,r7
move.l init_local_int.b(r4){s7},-(sp)
move.l uninit_local_int.b(r4){s7},-(sp)
movs.bl init_local_char.b(r4){s7},r0
move.l r0,-(sp)
movs.bl uninit_local_char.b(r4){s7},r0
move.l r0,-(sp)
move.l init_global_int,-(sp)
move.l uninit_global_int,-(sp)
movs.bl init_global_char,r0
move.l r0,-(sp)
movs.bl unint_global_char,r0
move.l r0,-(sp)
move.l #printf_format_string,-(sp)
bsr.l printf
addq.l #48,r7
unlk.l r4
rts.l
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

even 16,nop
start2: move.l r4,-(sp)
move.l r7,r4
move.l r6,-(sp)
move.l r5,-(sp)
eor.l r5,r5
move.l r3,-(sp)
subq.l #12,r7
bsr.l start3
add.l #$1220,r3
bsr.l init
lea.l -$f4(r3),r1
lea.l -$f4(r3),r0
sub.l r0,r1
asr.l #2,r1
cmp.l r1,r5
bcc.b _20
move.l r1,r6
dc.b $8d,$b4,$26,$00,$00,$00,$00 ;lea.l 0(r5),r5 7byte nop
dc.b $8d,$bc,$27,$00,$00,$00,$00 ;lea.l 0(r6),r6 7byte nop
_10: jsr.l (-$f4(r3,r5*4))
inc.l r5
cmp.l r6,r5
bcs.b _10
_20: addq.l #12,r7
move.l (sp)+,r3
move.l (sp)+,r5
move.l (sp)+,r6
move.l (sp)+,r4
rts.l

lea.l 0(r5),r5 ; 6byte nop
lea.l 0(r6),r6 ; 6byte nop

start1: move.l r4,-(sp)
move.l r7,r4
subq.l #8,r7
move.l r3,(r7){s7}
bsr.l start3
add.l #$000011c2,r3
move.l r5,4.b(r7){s7}
lea.l $ffffff0c(r3),r0
lea.l $ffffff0c(r3),r1
sub.l r1,r0
asr.l #2,r0
tst.l r0,r0
lea.l -1.b(r0),r5
bne.b _10
_20: bsr.l cleanup
move.l (r7){s7},r3
move.l 4.b(r7){s7},r5
move.l r4,r7
move.l (sp)+,r4
rts.l

_10: jsr.l ($ffffff0c(r3,r5*4))
move.l r5,r0
dec.l r5
tst.l r0,r0
bne.b _10
br.b _20

start3: move.l (r7){s7},r3
rts.l

even 16,nop
init3: move.l r4,-(sp)
move.l r7,r4
move.l r3,-(sp)
move.l r1,-(sp)
move.l #var4,r3
move.l var4,r0
br.b _20
br.b _10

even 16,nop
_10: subq.l #4,r3
jsr.l (r0)
move.l (r3),r0
_20: cmpq.l #-1,r0
bne.b _10
move.l (sp)+,r0
move.l (sp)+,r3
move.l (sp)+,r4
rts.l

SECT12_size=@@-SECT12_offset
;-----------------------------------------------------------------------------
;--- End of Section 12 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 13 ---
;-----------------------------------------------------------------------------
SECT13_name=sect_name14 ; ".fini"
SECT13_type=1 ; SHT_PROGBITS
SECT13_flags=6 ; SHF_ALLOC + SHF_EXECINSTR
SECT13_link=0
SECT13_info=0
SECT13_addralign=4
SECT13_entsize=0
even SECT13_addralign
SECT13_offset=@@
SECT13_addr:


DT_FINI:
cleanup:move.l r4,-(sp)
move.l r7,r4
move.l r3,-(sp)
bsr.l _10
_10: move.l (sp)+,r3
add.l #$1137,r3
move.l r1,-(sp)
bsr.l cleanup1
move.l -4.b(r4){s7},r3
unlk.l r4
rts.l


SECT13_size=@@-SECT13_offset
;-----------------------------------------------------------------------------
;--- End of Section 13 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 14 ---
;-----------------------------------------------------------------------------
SECT14_name=sect_name15 ; ".rodata"
SECT14_type=1 ; SHT_PROGBITS
SECT14_flags=2 ; SHF_ALLOC
SECT14_link=0
SECT14_info=0
SECT14_addralign=4
SECT14_entsize=0
even SECT14_addralign
SECT14_offset=@@
SECT14_addr:

dc.l $00000003
IO_stdin_used: dc.l $00020001

printf_format_string: dc.b "hello world %d %d %d %d %d %d %d %d",10,0

SECT14_size=@@-SECT14_offset
;-----------------------------------------------------------------------------
;--- End of Section 14 ---
;-----------------------------------------------------------------------------

SEGM02_filez=@@-SEGM02_offset
SEGM02_memsz=@-SEGM02_vaddr
;=============================================================================
;=== End of Segment 2 ===
;=============================================================================


;=============================================================================
;=== Start of Segment 3 ===
;=============================================================================

SEGM03_type=1 ; PT_LOAD Loadable segment
SEGM03_flags=6 ; PF_R + PF_W (1: execute 2: write 4:read)
SEGM03_align=4096
even 4
@=(@+SEGM03_align-1)/SEGM03_align*SEGM03_align+(@@\SEGM03_align)
SEGM03_offset=@@
SEGM03_vaddr:
SEGM03_paddr:


;-----------------------------------------------------------------------------
;--- Start of Section 15 ---
;-----------------------------------------------------------------------------
SECT15_name=sect_name16 ; ".data"
SECT15_type=1 ; SHT_PROGBITS
SECT15_flags=3 ; SHF_ALLOC + SHF_WRITE
SECT15_link=0
SECT15_info=0
SECT15_addralign=4
SECT15_entsize=0
even SECT15_addralign
SECT15_offset=@@
SECT15_addr:

dc.l 0
dc.l 0
var2: dc.l var5
init_global_char: dc.l 1
init_global_int: dc.l 2

SECT15_size=@@-SECT15_offset
;-----------------------------------------------------------------------------
;--- End of Section 15 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 16 ---
;-----------------------------------------------------------------------------
SECT16_name=sect_name17 ; ".eh_frame"
SECT16_type=1 ; SHT_PROGBITS
SECT16_flags=2 ; SHF_ALLOC
SECT16_link=0
SECT16_info=0
SECT16_addralign=4
SECT16_entsize=0
even SECT16_addralign
SECT16_offset=@@
SECT16_addr:

dc.l 0

SECT16_size=@@-SECT16_offset
;-----------------------------------------------------------------------------
;--- End of Section 16 ---
;-----------------------------------------------------------------------------


;=============================================================================
;=== Start of Segment 4 ===
;=============================================================================
SEGM04_type=2 ; PT_DYNAMIC Dynamic linking
SEGM04_flags=6 ; PF_R + PF_W (1: execute 2: write 4:read)
SEGM04_align=4
even SEGM04_align ; oder "even 4" ??????????
SEGM04_offset=@@
SEGM04_vaddr:
SEGM04_paddr:


;-----------------------------------------------------------------------------
;--- Start of Section 17 ---
;-----------------------------------------------------------------------------
SECT17_name=sect_name18 ; ".dynamic"
SECT17_type=6 ; SHT_DYNAMIC
SECT17_flags=3 ; SHF_ALLOC + SHF_EXECINSTR
SECT17_link=5 ; string tabel -> SECT05
SECT17_info=0
SECT17_addralign=4
SECT17_entsize=8
even SECT17_addralign
SECT17_offset=@@
SECT17_addr:

DYNAMIC:
dc.l 1, DT_NEEDED ; DT_NEEDED
dc.l 12, DT_INIT ; DT_INIT
dc.l 13, DT_FINI ; DT_FINI
dc.l 4, DT_HASH ; DT_HASH
dc.l 5, DT_STRTAB ; DT_STRTAB
dc.l 6, DT_SYMTAB ; DT_SYMTAB
dc.l 10, DT_STRSZ ; DT_STRSZ
dc.l 11, DT_SYMENT ; DT_SYMENT
dc.l 21, 0 ; DT_DEBUG
dc.l 3, DT_PLTGOT ; DT_PLTGOT
dc.l 2, DT_PLTRELSZ ; DT_PLTRELSZ
dc.l 20, 17 ; DT_PLTREL -> DT_REL
dc.l 23, DT_JUMPREL ; DT_JUMPREL
dc.l 17, DT_REL ; DT_REL
dc.l 18, DT_RELSZ ; DT_RELSZ
dc.l 19, DT_RELENT ; DT_RELENT
dc.l $6ffffffe, DT_X ; ???
dc.l $6fffffff, $00000001 ; ???
dc.l $6ffffff0, DT_Y ; ???
dc.l 0, $00000000 ; DT_NULL
dc.l 0, $00000000 ; DT_NULL
dc.l 0, $00000000 ; DT_NULL
dc.l 0, $00000000 ; DT_NULL
dc.l 0, $00000000 ; DT_NULL
dc.l 0, $00000000 ; DT_NULL



SECT17_size=@@-SECT17_offset
;-----------------------------------------------------------------------------
;--- End of Section 17 ---
;-----------------------------------------------------------------------------

SEGM04_filez=@@-SEGM04_offset
SEGM04_memsz=@-SEGM04_vaddr

;=============================================================================
;=== End of Segment 4 ===
;=============================================================================



;-----------------------------------------------------------------------------
;--- Start of Section 18 ---
;-----------------------------------------------------------------------------
SECT18_name=sect_name19 ; ".stors"
SECT18_type=1 ; SHT_PROGBITS
SECT18_flags=3 ; SHF_ALLOC + SHF_WRITE
SECT18_link=0
SECT18_info=0
SECT18_addralign=4
SECT18_entsize=0
even SECT18_addralign
SECT18_offset=@@
SECT18_addr:

var4: dc.l -1
dc.l 0

SECT18_size=@@-SECT18_offset
;-----------------------------------------------------------------------------
;--- End of Section 18 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 19 ---
;-----------------------------------------------------------------------------
SECT19_name=sect_name20 ; ".dtors"
SECT19_type=1 ; SHT_PROGBITS
SECT19_flags=3 ; SHF_ALLOC + SHF_WRITE
SECT19_link=0
SECT19_info=0
SECT19_addralign=4
SECT19_entsize=0
even SECT19_addralign
SECT19_offset=@@
SECT19_addr:


dc.l -1
var5: dc.l 0

SECT19_size=@@-SECT19_offset
;-----------------------------------------------------------------------------
;--- End of Section 19 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 20 ---
;-----------------------------------------------------------------------------
SECT20_name=sect_name21 ; ".jcr"
SECT20_type=1 ; SHT_PROGBITS
SECT20_flags=3 ; SHF_ALLOC + SHF_WRITE
SECT20_link=0
SECT20_info=0
SECT20_addralign=4
SECT20_entsize=0
even SECT20_addralign
SECT20_offset=@@
SECT20_addr:

var3: dc.l 0

SECT20_size=@@-SECT20_offset
;-----------------------------------------------------------------------------
;--- End of Section 20 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 21 ---
;-----------------------------------------------------------------------------
SECT21_name=sect_name22 ; ".got"
SECT21_type=1 ; SHT_PROGBITS
SECT21_flags=3 ; SHF_ALLOC + SHF_WRITE
SECT21_link=0
SECT21_info=0
SECT21_addralign=4
SECT21_entsize=4
even SECT21_addralign
SECT21_offset=@@
SECT21_addr:

DT_PLTGOT:

dc.l DYNAMIC ; reserved for address of dynamic structure
got1: dc.l 0 ; reserved (inserted by loader, info for late bind.)
got2: dc.l 0 ; reserved (inserted by loader, ptr to dyn. linker)

got_libc_start_main:
dc.l bind_libc_start_main

got_printf:
dc.l bind_printf ; replaced by address of printf (by loader or

; by bind_printf if late binding)
gmon_start:
dc.l 0

SECT21_size=@@-SECT21_offset
;-----------------------------------------------------------------------------
;--- End of Section 21 ---
;-----------------------------------------------------------------------------



;-----------------------------------------------------------------------------
;--- Start of Section 22 ---
;-----------------------------------------------------------------------------
SECT22_name=sect_name23 ; ".bss"
SECT22_type=8 ; SHT_NOBITS
SECT22_flags=3 ; SHF_ALLOC + SHF_WRITE
SECT22_link=0
SECT22_info=0
SECT22_addralign=4
SECT22_entsize=0
even SECT22_addralign
SECT22_offset=@@
SECT22_addr:

var1: blk.b 1
blk.b 3 ; even 4
unint_global_char: blk.l 1
uninit_global_int: blk.l 1


; SECT22_size=@@-SECT22_offset ; should be correct
SECT22_size=12 ; because of SHT_NOBITS also ok
;-----------------------------------------------------------------------------
;--- End of Section 22 ---
;-----------------------------------------------------------------------------

SEGM03_filez=@@-SEGM03_offset
SEGM03_memsz=@-SEGM03_vaddr
;=============================================================================
;=== End of Segment 3 ===
;=============================================================================


;-----------------------------------------------------------------------------
;--- Start of Section 23 ---
;-----------------------------------------------------------------------------
SECT23_name=sect_name24 ; ".comment"
SECT23_type=1 ; SHT_PROGBITS
SECT23_flags=0
SECT23_link=0
SECT23_info=0
SECT23_addralign=1
SECT23_entsize=0
even SECT23_addralign
SECT23_offset=@@
SECT23_addr=0

dc.b 0,"GCC: (GNU) 3.3.5 (Debian 1:3.3.5-1)",0
dc.b 0,"GCC: (GNU) 3.3.5 (Debian 1:3.3.5-1)",0
dc.b 0,"GCC: (GNU) 3.4.4 20041128 (prerelease) (Debian 3.4.3-3)",0
dc.b 0,"GCC: (GNU) 3.4.4 20041128 (prerelease) (Debian 3.4.3-3)",0
dc.b 0,"GCC: (GNU) 3.3.5 (Debian 1:3.3.5-1)",0
dc.b 0,"GCC: (GNU) 3.4.4 20041128 (prerelease) (Debian 3.4.3-3)",0
dc.b 0,"GCC: (GNU) 3.3.5 (Debian 1:3.3.5-1)",0

SECT23_size=@@-SECT23_offset
;-----------------------------------------------------------------------------
;--- End of Section 23 ---
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;--- Start of Section 24 ---
;-----------------------------------------------------------------------------
SECT24_name=sect_name01 ; ".shstrtab"
SECT24_type=3 ; SHT_STRTAB
SECT24_flags=0
SECT24_link=0
SECT24_info=0
SECT24_addralign=1
SECT24_entsize=0
even SECT24_addralign
SECT24_offset=@@
SECT24_addr=0

e_shstrndx=24

@1=@
sect_name00=@-@1
dc.b 0
sect_name01=@-@1
dc.b ".shstrtab",0
sect_name02=@-@1
dc.b ".interp",0
sect_name03=@-@1
dc.b ".note.ABI-tag",0
sect_name04=@-@1
dc.b ".hash",0
sect_name05=@-@1
dc.b ".dynsym",0
sect_name06=@-@1
dc.b ".dynstr",0
sect_name07=@-@1
dc.b ".gnu.version",0
sect_name08=@-@1
dc.b ".gnu.version_r",0
sect_name09=@-@1
dc.b ".rel.dyn",0
sect_name10=@-@1
dc.b ".rel"
sect_name11=@-@1
dc.b ".plt",0
sect_name12=@-@1
dc.b ".init",0
sect_name13=@-@1
dc.b ".text",0
sect_name14=@-@1
dc.b ".fini",0
sect_name15=@-@1
dc.b ".rodata",0
sect_name16=@-@1
dc.b ".data",0
sect_name17=@-@1
dc.b ".eh_frame",0
sect_name18=@-@1
dc.b ".dynamic",0
sect_name19=@-@1
dc.b ".ctors",0
sect_name20=@-@1
dc.b ".dtors",0
sect_name21=@-@1
dc.b ".jcr",0
sect_name22=@-@1
dc.b ".got",0
sect_name23=@-@1
dc.b ".bss",0
sect_name24=@-@1
dc.b ".comment",0

SECT24_size=@@-SECT24_offset
;-----------------------------------------------------------------------------
;--- End of Section 24 ---
;-----------------------------------------------------------------------------


;*****************************************************************************
;*** Start of Section header table ***
;*****************************************************************************
even 4
e_shoff=@@

; section 0
dc.l 0 ; sh_name
dc.l 0 ; sh_type
dc.l 0 ; sh_flags
dc.l 0 ; sh_addr
dc.l 0 ; sh_offset
dc.l 0 ; sh_size
dc.l 0 ; sh_link
dc.l 0 ; sh_info
dc.l 0 ; sh_addralign
dc.l 0 ; sh_entsize

e_shentsize=@@-e_shoff

; section 1
dc.l SECT01_name ; sh_name
dc.l SECT01_type ; sh_type
dc.l SECT01_flags ; sh_flags
dc.l SECT01_addr ; sh_addr
dc.l SECT01_offset ; sh_offset
dc.l SECT01_size ; sh_size
dc.l SECT01_link ; sh_link
dc.l SECT01_info ; sh_info
dc.l SECT01_addralign; sh_addralign
dc.l SECT01_entsize ; sh_entsize

; section 2
dc.l SECT02_name ; sh_name
dc.l SECT02_type ; sh_type
dc.l SECT02_flags ; sh_flags
dc.l SECT02_addr ; sh_addr
dc.l SECT02_offset ; sh_offset
dc.l SECT02_size ; sh_size
dc.l SECT02_link ; sh_link
dc.l SECT02_info ; sh_info
dc.l SECT02_addralign; sh_addralign
dc.l SECT02_entsize ; sh_entsize

; section 3
dc.l SECT03_name ; sh_name
dc.l SECT03_type ; sh_type
dc.l SECT03_flags ; sh_flags
dc.l SECT03_addr ; sh_addr
dc.l SECT03_offset ; sh_offset
dc.l SECT03_size ; sh_size
dc.l SECT03_link ; sh_link
dc.l SECT03_info ; sh_info
dc.l SECT03_addralign; sh_addralign
dc.l SECT03_entsize ; sh_entsize

; section 4
dc.l SECT04_name ; sh_name
dc.l SECT04_type ; sh_type
dc.l SECT04_flags ; sh_flags
dc.l SECT04_addr ; sh_addr
dc.l SECT04_offset ; sh_offset
dc.l SECT04_size ; sh_size
dc.l SECT04_link ; sh_link
dc.l SECT04_info ; sh_info
dc.l SECT04_addralign; sh_addralign
dc.l SECT04_entsize ; sh_entsize

; section 5
dc.l SECT05_name ; sh_name
dc.l SECT05_type ; sh_type
dc.l SECT05_flags ; sh_flags
dc.l SECT05_addr ; sh_addr
dc.l SECT05_offset ; sh_offset
dc.l SECT05_size ; sh_size
dc.l SECT05_link ; sh_link
dc.l SECT05_info ; sh_info
dc.l SECT05_addralign; sh_addralign
dc.l SECT05_entsize ; sh_entsize

; section 6
dc.l SECT06_name ; sh_name
dc.l SECT06_type ; sh_type
dc.l SECT06_flags ; sh_flags
dc.l SECT06_addr ; sh_addr
dc.l SECT06_offset ; sh_offset
dc.l SECT06_size ; sh_size
dc.l SECT06_link ; sh_link
dc.l SECT06_info ; sh_info
dc.l SECT06_addralign; sh_addralign
dc.l SECT06_entsize ; sh_entsize

; section 7
dc.l SECT07_name ; sh_name
dc.l SECT07_type ; sh_type
dc.l SECT07_flags ; sh_flags
dc.l SECT07_addr ; sh_addr
dc.l SECT07_offset ; sh_offset
dc.l SECT07_size ; sh_size
dc.l SECT07_link ; sh_link
dc.l SECT07_info ; sh_info
dc.l SECT07_addralign; sh_addralign
dc.l SECT07_entsize ; sh_entsize

; section 8
dc.l SECT08_name ; sh_name
dc.l SECT08_type ; sh_type
dc.l SECT08_flags ; sh_flags
dc.l SECT08_addr ; sh_addr
dc.l SECT08_offset ; sh_offset
dc.l SECT08_size ; sh_size
dc.l SECT08_link ; sh_link
dc.l SECT08_info ; sh_info
dc.l SECT08_addralign; sh_addralign
dc.l SECT08_entsize ; sh_entsize

; section 9
dc.l SECT09_name ; sh_name
dc.l SECT09_type ; sh_type
dc.l SECT09_flags ; sh_flags
dc.l SECT09_addr ; sh_addr
dc.l SECT09_offset ; sh_offset
dc.l SECT09_size ; sh_size
dc.l SECT09_link ; sh_link
dc.l SECT09_info ; sh_info
dc.l SECT09_addralign; sh_addralign
dc.l SECT09_entsize ; sh_entsize

; section 10
dc.l SECT10_name ; sh_name
dc.l SECT10_type ; sh_type
dc.l SECT10_flags ; sh_flags
dc.l SECT10_addr ; sh_addr
dc.l SECT10_offset ; sh_offset
dc.l SECT10_size ; sh_size
dc.l SECT10_link ; sh_link
dc.l SECT10_info ; sh_info
dc.l SECT10_addralign; sh_addralign
dc.l SECT10_entsize ; sh_entsize

; section 11
dc.l SECT11_name ; sh_name
dc.l SECT11_type ; sh_type
dc.l SECT11_flags ; sh_flags
dc.l SECT11_addr ; sh_addr
dc.l SECT11_offset ; sh_offset
dc.l SECT11_size ; sh_size
dc.l SECT11_link ; sh_link
dc.l SECT11_info ; sh_info
dc.l SECT11_addralign; sh_addralign
dc.l SECT11_entsize ; sh_entsize

; section 12
dc.l SECT12_name ; sh_name
dc.l SECT12_type ; sh_type
dc.l SECT12_flags ; sh_flags
dc.l SECT12_addr ; sh_addr
dc.l SECT12_offset ; sh_offset
dc.l SECT12_size ; sh_size
dc.l SECT12_link ; sh_link
dc.l SECT12_info ; sh_info
dc.l SECT12_addralign; sh_addralign
dc.l SECT12_entsize ; sh_entsize

; section 13
dc.l SECT13_name ; sh_name
dc.l SECT13_type ; sh_type
dc.l SECT13_flags ; sh_flags
dc.l SECT13_addr ; sh_addr
dc.l SECT13_offset ; sh_offset
dc.l SECT13_size ; sh_size
dc.l SECT13_link ; sh_link
dc.l SECT13_info ; sh_info
dc.l SECT13_addralign; sh_addralign
dc.l SECT13_entsize ; sh_entsize

; section 14
dc.l SECT14_name ; sh_name
dc.l SECT14_type ; sh_type
dc.l SECT14_flags ; sh_flags
dc.l SECT14_addr ; sh_addr
dc.l SECT14_offset ; sh_offset
dc.l SECT14_size ; sh_size
dc.l SECT14_link ; sh_link
dc.l SECT14_info ; sh_info
dc.l SECT14_addralign; sh_addralign
dc.l SECT14_entsize ; sh_entsize

; section 15
dc.l SECT15_name ; sh_name
dc.l SECT15_type ; sh_type
dc.l SECT15_flags ; sh_flags
dc.l SECT15_addr ; sh_addr
dc.l SECT15_offset ; sh_offset
dc.l SECT15_size ; sh_size
dc.l SECT15_link ; sh_link
dc.l SECT15_info ; sh_info
dc.l SECT15_addralign; sh_addralign
dc.l SECT15_entsize ; sh_entsize

; section 16
dc.l SECT16_name ; sh_name
dc.l SECT16_type ; sh_type
dc.l SECT16_flags ; sh_flags
dc.l SECT16_addr ; sh_addr
dc.l SECT16_offset ; sh_offset
dc.l SECT16_size ; sh_size
dc.l SECT16_link ; sh_link
dc.l SECT16_info ; sh_info
dc.l SECT16_addralign; sh_addralign
dc.l SECT16_entsize ; sh_entsize

; section 17
dc.l SECT17_name ; sh_name
dc.l SECT17_type ; sh_type
dc.l SECT17_flags ; sh_flags
dc.l SECT17_addr ; sh_addr
dc.l SECT17_offset ; sh_offset
dc.l SECT17_size ; sh_size
dc.l SECT17_link ; sh_link
dc.l SECT17_info ; sh_info
dc.l SECT17_addralign; sh_addralign
dc.l SECT17_entsize ; sh_entsize

; section 18
dc.l SECT18_name ; sh_name
dc.l SECT18_type ; sh_type
dc.l SECT18_flags ; sh_flags
dc.l SECT18_addr ; sh_addr
dc.l SECT18_offset ; sh_offset
dc.l SECT18_size ; sh_size
dc.l SECT18_link ; sh_link
dc.l SECT18_info ; sh_info
dc.l SECT18_addralign; sh_addralign
dc.l SECT18_entsize ; sh_entsize

; section 19
dc.l SECT19_name ; sh_name
dc.l SECT19_type ; sh_type
dc.l SECT19_flags ; sh_flags
dc.l SECT19_addr ; sh_addr
dc.l SECT19_offset ; sh_offset
dc.l SECT19_size ; sh_size
dc.l SECT19_link ; sh_link
dc.l SECT19_info ; sh_info
dc.l SECT19_addralign; sh_addralign
dc.l SECT19_entsize ; sh_entsize

; section 20
dc.l SECT20_name ; sh_name
dc.l SECT20_type ; sh_type
dc.l SECT20_flags ; sh_flags
dc.l SECT20_addr ; sh_addr
dc.l SECT20_offset ; sh_offset
dc.l SECT20_size ; sh_size
dc.l SECT20_link ; sh_link
dc.l SECT20_info ; sh_info
dc.l SECT20_addralign; sh_addralign
dc.l SECT20_entsize ; sh_entsize

; section 21
dc.l SECT21_name ; sh_name
dc.l SECT21_type ; sh_type
dc.l SECT21_flags ; sh_flags
dc.l SECT21_addr ; sh_addr
dc.l SECT21_offset ; sh_offset
dc.l SECT21_size ; sh_size
dc.l SECT21_link ; sh_link
dc.l SECT21_info ; sh_info
dc.l SECT21_addralign; sh_addralign
dc.l SECT21_entsize ; sh_entsize

; section 22
dc.l SECT22_name ; sh_name
dc.l SECT22_type ; sh_type
dc.l SECT22_flags ; sh_flags
dc.l SECT22_addr ; sh_addr
dc.l SECT22_offset ; sh_offset
dc.l SECT22_size ; sh_size
dc.l SECT22_link ; sh_link
dc.l SECT22_info ; sh_info
dc.l SECT22_addralign; sh_addralign
dc.l SECT22_entsize ; sh_entsize

; section 23
dc.l SECT23_name ; sh_name
dc.l SECT23_type ; sh_type
dc.l SECT23_flags ; sh_flags
dc.l SECT23_addr ; sh_addr
dc.l SECT23_offset ; sh_offset
dc.l SECT23_size ; sh_size
dc.l SECT23_link ; sh_link
dc.l SECT23_info ; sh_info
dc.l SECT23_addralign; sh_addralign
dc.l SECT23_entsize ; sh_entsize

; section 24
dc.l SECT24_name ; sh_name
dc.l SECT24_type ; sh_type
dc.l SECT24_flags ; sh_flags
dc.l SECT24_addr ; sh_addr
dc.l SECT24_offset ; sh_offset
dc.l SECT24_size ; sh_size
dc.l SECT24_link ; sh_link
dc.l SECT24_info ; sh_info
dc.l SECT24_addralign; sh_addralign
dc.l SECT24_entsize ; sh_entsize

e_shnum=(@@-e_shoff)/e_shentsize

;*****************************************************************************
;*** End of Section header table ***
;*****************************************************************************
From: Chuck Crayne on
On Tue, 15 Apr 2008 21:49:35 GMT
Frank Kotler <fbkotler(a)verizon.net> wrote:

> So now I can build "suicidal executables" any time I want -
> and so can you!

And so can we all. Using this new toy, I can see why having a .data
section makes a difference. Apparently assuming that NOBODY would be
crazy enough to have a .bss section without also having a .data
section, the "bad" linker builds a single program header entry which
includes both the .data and .bss sections (in that order) so, as long as
the .data section is correctly aligned, there is no need to align
the .bss section. Then, along comes some crazy assembly language
programmer . . .

--
Chuck
http://www.pacificsites.com/~ccrayne/charles.html


From: Frank Kotler on
Chuck Crayne wrote:
> On Tue, 15 Apr 2008 21:49:35 GMT
> Frank Kotler <fbkotler(a)verizon.net> wrote:
>
>> So now I can build "suicidal executables" any time I want -
>> and so can you!
>
> And so can we all. Using this new toy, I can see why having a .data
> section makes a difference. Apparently assuming that NOBODY would be
> crazy enough to have a .bss section without also having a .data
> section, the "bad" linker builds a single program header entry which
> includes both the .data and .bss sections (in that order) so, as long as
> the .data section is correctly aligned, there is no need to align
> the .bss section. Then, along comes some crazy assembly language
> programmer . . .

Yeah... This issue confused me. I didn't expect the Gas example
(sys_exit with .bss) to get killed. When we were looking at the "last
section must be writeable" issue, I observed that Gas users wouldn't
ever see it, because Gas added a .data section, whether we asked for it
or not. Still does, in the object file, and with an older ld (2.13), in
the executable, too. But newer ld versions (2.17.50.bad.day and 2.18)
*don't* have a .data section in the executable, and so get killed.
Incidentally, I tried Fasm, and its object files, linked with the "bad"
version, get killed, too.

Come back, Ivan! It was only a bad linker! (if he'd posted the failing
executable, we could have pinned it on the linker a lot sooner, probably)

Best,
Frank
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12
Prev: Sudoku
Next: Linux distro request