"Fossies" - the Fresh Open Source Software Archive

Member "fasm/examples/elfexe/dynamic/import32.inc" (9 Feb 2020, 1287 Bytes) of package /linux/misc/fasm-1.73.22.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) fasm source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 include 'elf.inc'
    3 
    4 macro interpreter [library]
    5 {
    6  segment interpreter readable
    7  db library,0
    8 }
    9 
   10 macro needed [library]
   11 {
   12  local str
   13  match needed,needed@dynamic \{ define needed@dynamic needed,str:library \}
   14  match ,needed@dynamic \{ define needed@dynamic str:library \}
   15 }
   16 define needed@dynamic
   17 
   18 macro import [name]
   19 {
   20  common
   21   local strtab,strsz,symtab,rel,relsz,hash
   22   segment dynamic readable
   23   match needed,needed@dynamic
   24   \{ irp item,needed \\{ match str:library,item \\\{ dd DT_NEEDED,str-strtab \\\} \\} \}
   25   dd DT_STRTAB,strtab
   26   dd DT_STRSZ,strsz
   27   dd DT_SYMTAB,symtab
   28   dd DT_SYMENT,sizeof.Elf32_Sym
   29   dd DT_REL,rel
   30   dd DT_RELSZ,relsz
   31   dd DT_RELENT,sizeof.Elf32_Rel
   32   dd DT_HASH,hash
   33   dd DT_NULL,0
   34   segment readable writeable
   35   symtab: Elf32_Sym
   36  forward
   37   local fstr
   38   Elf32_Sym fstr-strtab,0,0,STB_GLOBAL,STT_FUNC,0,0
   39  common
   40   rel:
   41   local counter
   42   counter = 1
   43  forward
   44    Elf32_Rel name,counter,R_386_32
   45    counter = counter+1
   46  common
   47   relsz = $-rel
   48   hash:
   49   dd 1,counter
   50   dd 0
   51   repeat counter
   52    if %=counter
   53     dd 0
   54    else
   55     dd %
   56    end if
   57   end repeat
   58   strtab db 0
   59  forward
   60   fstr db `name,0
   61  common
   62   match needed,needed@dynamic
   63   \{ irp item,needed \\{ match str:library,item \\\{ str db library,0 \\\} \\} \}
   64   strsz = $-strtab
   65  forward
   66   name dd 0
   67 }