Merge git://github.com/erikcharlebois/factor
commit
54b357eb63
|
@ -58,8 +58,6 @@ SINGLETON: pbm-image
|
||||||
read-token :> type
|
read-token :> type
|
||||||
read-number :> width
|
read-number :> width
|
||||||
read-number :> height
|
read-number :> height
|
||||||
width height * :> npixels
|
|
||||||
width 8 mod :> leftover
|
|
||||||
|
|
||||||
type {
|
type {
|
||||||
{ "P1" [ [ [ read-ascii-bits ] ignore-errors ] B{ } make ] }
|
{ "P1" [ [ [ read-ascii-bits ] ignore-errors ] B{ } make ] }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2010 Erik Charlebois.
|
! Copyright (C) 2010 Erik Charlebois.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien alien.c-types alien.strings alien.syntax arrays
|
USING: accessors alien alien.c-types alien.strings alien.syntax arrays
|
||||||
classes.struct io.encodings.ascii kernel locals math math.intervals
|
classes.struct fry io.encodings.ascii kernel locals math
|
||||||
sequences specialized-arrays strings typed ;
|
math.intervals sequences specialized-arrays strings typed ;
|
||||||
IN: elf
|
IN: elf
|
||||||
|
|
||||||
! FFI data
|
! FFI data
|
||||||
|
@ -609,4 +609,6 @@ M:: segment sections ( segment -- sections )
|
||||||
symbol sym>> st_value>> segment p_vaddr>> - segment p_offset>> + :> faddress
|
symbol sym>> st_value>> segment p_vaddr>> - segment p_offset>> + :> faddress
|
||||||
faddress symbol elf-header>> >c-ptr <displaced-alien>
|
faddress symbol elf-header>> >c-ptr <displaced-alien>
|
||||||
symbol sym>> st_size>> <direct-uchar-array> ;
|
symbol sym>> st_size>> <direct-uchar-array> ;
|
||||||
|
|
||||||
|
: find-section ( sections name -- section/f )
|
||||||
|
'[ name>> _ = ] find nip ;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Erik Charlebois
|
|
@ -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"
|
|
@ -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 ;
|
|
@ -0,0 +1 @@
|
||||||
|
UNIX nm-like utility.
|
Loading…
Reference in New Issue