Merge git://github.com/erikcharlebois/factor

release
Joe Groff 2010-04-12 19:17:37 -07:00
commit 54b357eb63
6 changed files with 54 additions and 5 deletions

View File

@ -58,8 +58,6 @@ SINGLETON: pbm-image
read-token :> type
read-number :> width
read-number :> height
width height * :> npixels
width 8 mod :> leftover
type {
{ "P1" [ [ [ read-ascii-bits ] ignore-errors ] B{ } make ] }

View File

@ -1,8 +1,8 @@
! Copyright (C) 2010 Erik Charlebois.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types alien.strings alien.syntax arrays
classes.struct io.encodings.ascii kernel locals math math.intervals
sequences specialized-arrays strings typed ;
classes.struct fry io.encodings.ascii kernel locals math
math.intervals sequences specialized-arrays strings typed ;
IN: elf
! FFI data
@ -609,4 +609,6 @@ M:: segment sections ( segment -- sections )
symbol sym>> st_value>> segment p_vaddr>> - segment p_offset>> + :> faddress
faddress symbol elf-header>> >c-ptr <displaced-alien>
symbol sym>> st_size>> <direct-uchar-array> ;
: find-section ( sections name -- section/f )
'[ name>> _ = ] find nip ;

1
extra/elf/nm/authors.txt Normal file
View File

@ -0,0 +1 @@
Erik Charlebois

View File

@ -0,0 +1,22 @@
! Copyright (C) 2010 Erik Charlebois.
! See http://factorcode.org/license.txt for BSD license.
USING: elf help.markup help.syntax ;
IN: elf.nm
HELP: nm
{ $values
{ "path" "a pathname string" }
}
{ $description "Prints information about the symbols in the ELF object at the given path." } ;
HELP: print-symbol
{ $values
{ "sections" "sequence of section" } { "symbol" symbol }
}
{ $description "Prints the value, section and name of the given symbol." } ;
ARTICLE: "elf.nm" "ELF nm"
{ $description "Utility to print the values, sections and names of the symbols in a given ELF file. In an ELF executable or shared library, the symbol values are typically their virtual addresses. In a relocatable ELF object, they are section-relative offsets." }
;
ABOUT: "elf.nm"

25
extra/elf/nm/nm.factor Normal file
View File

@ -0,0 +1,25 @@
! Copyright (C) 2010 Erik Charlebois.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators elf formatting io.mmap kernel sequences ;
IN: elf.nm
: print-symbol ( sections symbol -- )
[ sym>> st_value>> "%016d " printf ]
[
sym>> st_shndx>>
{
{ SHN_UNDEF [ drop "undefined" ] }
{ SHN_ABS [ drop "absolute" ] }
{ SHN_COMMON [ drop "common" ] }
[ swap nth name>> ]
} case "%-16s " printf
]
[ name>> "%s\n" printf ] tri ;
: nm ( path -- )
[
address>> <elf> sections
dup ".symtab" find-section
symbols [ name>> empty? not ] filter
[ print-symbol ] with each
] with-mapped-file ;

1
extra/elf/nm/summary.txt Normal file
View File

@ -0,0 +1 @@
UNIX nm-like utility.