You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(56) |
May
(48) |
Jun
(51) |
Jul
(55) |
Aug
(27) |
Sep
(12) |
Oct
(14) |
Nov
(14) |
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(22) |
Feb
(12) |
Mar
(16) |
Apr
(43) |
May
(20) |
Jun
(10) |
Jul
(63) |
Aug
(37) |
Sep
(7) |
Oct
(1) |
Nov
(22) |
Dec
(99) |
| 2010 |
Jan
(74) |
Feb
(36) |
Mar
(114) |
Apr
(64) |
May
(56) |
Jun
(55) |
Jul
(27) |
Aug
(93) |
Sep
(55) |
Oct
(40) |
Nov
(44) |
Dec
(51) |
| 2011 |
Jan
(62) |
Feb
(35) |
Mar
(24) |
Apr
(37) |
May
(45) |
Jun
(53) |
Jul
(95) |
Aug
(130) |
Sep
(162) |
Oct
(115) |
Nov
(158) |
Dec
(120) |
| 2012 |
Jan
(18) |
Feb
(55) |
Mar
(31) |
Apr
(25) |
May
(11) |
Jun
(9) |
Jul
(8) |
Aug
(32) |
Sep
(42) |
Oct
(45) |
Nov
(51) |
Dec
(150) |
| 2013 |
Jan
(54) |
Feb
(16) |
Mar
(16) |
Apr
(2) |
May
(11) |
Jun
(4) |
Jul
|
Aug
(10) |
Sep
(3) |
Oct
(1) |
Nov
|
Dec
(7) |
| 2014 |
Jan
(6) |
Feb
(3) |
Mar
(30) |
Apr
(16) |
May
(28) |
Jun
(19) |
Jul
(6) |
Aug
|
Sep
(16) |
Oct
(4) |
Nov
(3) |
Dec
(31) |
| 2015 |
Jan
(6) |
Feb
(2) |
Mar
(8) |
Apr
(10) |
May
(34) |
Jun
(3) |
Jul
(9) |
Aug
(10) |
Sep
(3) |
Oct
(7) |
Nov
(9) |
Dec
(24) |
| 2016 |
Jan
(97) |
Feb
(39) |
Mar
(13) |
Apr
(4) |
May
(33) |
Jun
(1) |
Jul
(1) |
Aug
(10) |
Sep
(4) |
Oct
(4) |
Nov
(1) |
Dec
(14) |
| 2017 |
Jan
(2) |
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
(42) |
Jul
(2) |
Aug
(4) |
Sep
(12) |
Oct
(3) |
Nov
(2) |
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(25) |
May
(2) |
Jun
|
Jul
(3) |
Aug
|
Sep
(10) |
Oct
(17) |
Nov
(4) |
Dec
(17) |
| 2019 |
Jan
(5) |
Feb
(27) |
Mar
(28) |
Apr
(8) |
May
(5) |
Jun
(29) |
Jul
(10) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2020 |
Jan
(17) |
Feb
(31) |
Mar
(25) |
Apr
(3) |
May
(1) |
Jun
(12) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
|
Nov
(42) |
Dec
(1) |
| 2021 |
Jan
|
Feb
(8) |
Mar
(12) |
Apr
(13) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2022 |
Jan
|
Feb
|
Mar
(14) |
Apr
(12) |
May
(10) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2023 |
Jan
(1) |
Feb
|
Mar
(12) |
Apr
(5) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(15) |
Nov
|
Dec
(8) |
| 2024 |
Jan
(9) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(2) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
(10) |
| 2025 |
Jan
(77) |
Feb
(51) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(11) |
Sep
(2) |
Oct
(56) |
Nov
|
Dec
|
|
From: <kai...@us...> - 2008-04-03 20:35:52
|
Revision: 6
http://elftoolchain.svn.sourceforge.net/elftoolchain/?rev=6&view=rev
Author: kaiwang27
Date: 2008-04-03 13:35:44 -0700 (Thu, 03 Apr 2008)
Log Message:
-----------
Import a snapshot of ar(1) from FreeBSD perforce repository.
Added Paths:
-----------
projects/ar/trunk/Makefile
projects/ar/trunk/acplex.l
projects/ar/trunk/acpyacc.y
projects/ar/trunk/ar.1
projects/ar/trunk/ar.c
projects/ar/trunk/ar.h
projects/ar/trunk/benchmark/
projects/ar/trunk/benchmark/acp.sh
projects/ar/trunk/read.c
projects/ar/trunk/svn-commit.2.tmp
projects/ar/trunk/svn-commit.3.tmp
projects/ar/trunk/svn-commit.4.tmp
projects/ar/trunk/svn-commit.tmp
projects/ar/trunk/test/
projects/ar/trunk/test/Makefile
projects/ar/trunk/test/func.sh
projects/ar/trunk/test/plugin/
projects/ar/trunk/test/plugin/Makefile.ardiff
projects/ar/trunk/test/plugin/Makefile.teraser
projects/ar/trunk/test/plugin/ardiff.c
projects/ar/trunk/test/plugin/teraser.c
projects/ar/trunk/test/run.sh
projects/ar/trunk/test/tc/
projects/ar/trunk/test/tc/addself-liba/
projects/ar/trunk/test/tc/addself-liba/addself-liba.err
projects/ar/trunk/test/tc/addself-liba/addself-liba.eval
projects/ar/trunk/test/tc/addself-liba/addself-liba.out
projects/ar/trunk/test/tc/addself-liba/addself-liba.sh
projects/ar/trunk/test/tc/addself-liba/in/
projects/ar/trunk/test/tc/addself-liba/in/addself-liba.in.shar
projects/ar/trunk/test/tc/addself-liba/out/
projects/ar/trunk/test/tc/addself-liba/out/addself-liba.out.shar
projects/ar/trunk/test/tc/archive-liba/
projects/ar/trunk/test/tc/archive-liba/archive-liba.err
projects/ar/trunk/test/tc/archive-liba/archive-liba.eval
projects/ar/trunk/test/tc/archive-liba/archive-liba.out
projects/ar/trunk/test/tc/archive-liba/archive-liba.sh
projects/ar/trunk/test/tc/archive-liba/in/
projects/ar/trunk/test/tc/archive-liba/in/archive-liba.in.shar
projects/ar/trunk/test/tc/archive-liba/out/
projects/ar/trunk/test/tc/archive-liba/out/archive-liba.out.shar
projects/ar/trunk/test/tc/archive-liba-v/
projects/ar/trunk/test/tc/archive-liba-v/archive-liba-v.err
projects/ar/trunk/test/tc/archive-liba-v/archive-liba-v.eval
projects/ar/trunk/test/tc/archive-liba-v/archive-liba-v.out
projects/ar/trunk/test/tc/archive-liba-v/archive-liba-v.sh
projects/ar/trunk/test/tc/archive-liba-v/in/
projects/ar/trunk/test/tc/archive-liba-v/in/archive-liba-v.in.shar
projects/ar/trunk/test/tc/archive-liba-v/out/
projects/ar/trunk/test/tc/archive-liba-v/out/archive-liba-v.out.shar
projects/ar/trunk/test/tc/archive-liblong/
projects/ar/trunk/test/tc/archive-liblong/archive-liblong.err
projects/ar/trunk/test/tc/archive-liblong/archive-liblong.eval
projects/ar/trunk/test/tc/archive-liblong/archive-liblong.out
projects/ar/trunk/test/tc/archive-liblong/archive-liblong.sh
projects/ar/trunk/test/tc/archive-liblong/in/
projects/ar/trunk/test/tc/archive-liblong/in/archive-liblong.in.shar
projects/ar/trunk/test/tc/archive-liblong/out/
projects/ar/trunk/test/tc/archive-liblong/out/archive-liblong.out.shar
projects/ar/trunk/test/tc/archive-libmix-v/
projects/ar/trunk/test/tc/archive-libmix-v/archive-libmix-v.err
projects/ar/trunk/test/tc/archive-libmix-v/archive-libmix-v.eval
projects/ar/trunk/test/tc/archive-libmix-v/archive-libmix-v.out
projects/ar/trunk/test/tc/archive-libmix-v/archive-libmix-v.sh
projects/ar/trunk/test/tc/archive-libmix-v/in/
projects/ar/trunk/test/tc/archive-libmix-v/in/archive-libmix-v.in.shar
projects/ar/trunk/test/tc/archive-libmix-v/out/
projects/ar/trunk/test/tc/archive-libmix-v/out/archive-libmix-v.out.shar
projects/ar/trunk/test/tc/archive-libnonelf-v/
projects/ar/trunk/test/tc/archive-libnonelf-v/archive-libnonelf-v.err
projects/ar/trunk/test/tc/archive-libnonelf-v/archive-libnonelf-v.eval
projects/ar/trunk/test/tc/archive-libnonelf-v/archive-libnonelf-v.out
projects/ar/trunk/test/tc/archive-libnonelf-v/archive-libnonelf-v.sh
projects/ar/trunk/test/tc/archive-libnonelf-v/in/
projects/ar/trunk/test/tc/archive-libnonelf-v/in/archive-libnonelf-v.in.shar
projects/ar/trunk/test/tc/archive-libnonelf-v/out/
projects/ar/trunk/test/tc/archive-libnonelf-v/out/archive-libnonelf-v.out.shar
projects/ar/trunk/test/tc/compbase-liba-v/
projects/ar/trunk/test/tc/compbase-liba-v/compbase-liba-v.err
projects/ar/trunk/test/tc/compbase-liba-v/compbase-liba-v.eval
projects/ar/trunk/test/tc/compbase-liba-v/compbase-liba-v.out
projects/ar/trunk/test/tc/compbase-liba-v/compbase-liba-v.sh
projects/ar/trunk/test/tc/compbase-liba-v/in/
projects/ar/trunk/test/tc/compbase-liba-v/in/compbase-liba-v.in.shar
projects/ar/trunk/test/tc/compbase-liba-v/out/
projects/ar/trunk/test/tc/compbase-liba-v/out/compbase-liba-v.out.shar
projects/ar/trunk/test/tc/compbase_read-liba/
projects/ar/trunk/test/tc/compbase_read-liba/compbase_read-liba.err
projects/ar/trunk/test/tc/compbase_read-liba/compbase_read-liba.eval
projects/ar/trunk/test/tc/compbase_read-liba/compbase_read-liba.out
projects/ar/trunk/test/tc/compbase_read-liba/compbase_read-liba.sh
projects/ar/trunk/test/tc/compbase_read-liba/in/
projects/ar/trunk/test/tc/compbase_read-liba/in/compbase_read-liba.in.shar
projects/ar/trunk/test/tc/compbase_read-liba/out/
projects/ar/trunk/test/tc/compbase_read-liba/out/compbase_read-liba.out.shar
projects/ar/trunk/test/tc/delete-liba-v/
projects/ar/trunk/test/tc/delete-liba-v/delete-liba-v.err
projects/ar/trunk/test/tc/delete-liba-v/delete-liba-v.eval
projects/ar/trunk/test/tc/delete-liba-v/delete-liba-v.out
projects/ar/trunk/test/tc/delete-liba-v/delete-liba-v.sh
projects/ar/trunk/test/tc/delete-liba-v/in/
projects/ar/trunk/test/tc/delete-liba-v/in/delete-liba-v.in.shar
projects/ar/trunk/test/tc/delete-liba-v/out/
projects/ar/trunk/test/tc/delete-liba-v/out/delete-liba-v.out.shar
projects/ar/trunk/test/tc/delete-liblong/
projects/ar/trunk/test/tc/delete-liblong/delete-liblong.err
projects/ar/trunk/test/tc/delete-liblong/delete-liblong.eval
projects/ar/trunk/test/tc/delete-liblong/delete-liblong.out
projects/ar/trunk/test/tc/delete-liblong/delete-liblong.sh
projects/ar/trunk/test/tc/delete-liblong/in/
projects/ar/trunk/test/tc/delete-liblong/in/delete-liblong.in.shar
projects/ar/trunk/test/tc/delete-liblong/out/
projects/ar/trunk/test/tc/delete-liblong/out/delete-liblong.out.shar
projects/ar/trunk/test/tc/delete-libmix-v/
projects/ar/trunk/test/tc/delete-libmix-v/delete-libmix-v.err
projects/ar/trunk/test/tc/delete-libmix-v/delete-libmix-v.eval
projects/ar/trunk/test/tc/delete-libmix-v/delete-libmix-v.out
projects/ar/trunk/test/tc/delete-libmix-v/delete-libmix-v.sh
projects/ar/trunk/test/tc/delete-libmix-v/in/
projects/ar/trunk/test/tc/delete-libmix-v/in/delete-libmix-v.in.shar
projects/ar/trunk/test/tc/delete-libmix-v/out/
projects/ar/trunk/test/tc/delete-libmix-v/out/delete-libmix-v.out.shar
projects/ar/trunk/test/tc/delete_all-liba-v/
projects/ar/trunk/test/tc/delete_all-liba-v/delete_all-liba-v.err
projects/ar/trunk/test/tc/delete_all-liba-v/delete_all-liba-v.eval
projects/ar/trunk/test/tc/delete_all-liba-v/delete_all-liba-v.out
projects/ar/trunk/test/tc/delete_all-liba-v/delete_all-liba-v.sh
projects/ar/trunk/test/tc/delete_all-liba-v/in/
projects/ar/trunk/test/tc/delete_all-liba-v/in/delete_all-liba-v.in.shar
projects/ar/trunk/test/tc/delete_all-liba-v/out/
projects/ar/trunk/test/tc/delete_all-liba-v/out/delete_all-liba-v.out.shar
projects/ar/trunk/test/tc/extract-liba/
projects/ar/trunk/test/tc/extract-liba/extract-liba.err
projects/ar/trunk/test/tc/extract-liba/extract-liba.eval
projects/ar/trunk/test/tc/extract-liba/extract-liba.out
projects/ar/trunk/test/tc/extract-liba/extract-liba.sh
projects/ar/trunk/test/tc/extract-liba/in/
projects/ar/trunk/test/tc/extract-liba/in/extract-liba.in.shar
projects/ar/trunk/test/tc/extract-liba/out/
projects/ar/trunk/test/tc/extract-liba/out/extract-liba.out.shar
projects/ar/trunk/test/tc/extract-liba-v/
projects/ar/trunk/test/tc/extract-liba-v/extract-liba-v.err
projects/ar/trunk/test/tc/extract-liba-v/extract-liba-v.eval
projects/ar/trunk/test/tc/extract-liba-v/extract-liba-v.out
projects/ar/trunk/test/tc/extract-liba-v/extract-liba-v.sh
projects/ar/trunk/test/tc/extract-liba-v/in/
projects/ar/trunk/test/tc/extract-liba-v/in/extract-liba-v.in.shar
projects/ar/trunk/test/tc/extract-liba-v/out/
projects/ar/trunk/test/tc/extract-liba-v/out/extract-liba-v.out.shar
projects/ar/trunk/test/tc/extract-liblong/
projects/ar/trunk/test/tc/extract-liblong/extract-liblong.err
projects/ar/trunk/test/tc/extract-liblong/extract-liblong.eval
projects/ar/trunk/test/tc/extract-liblong/extract-liblong.out
projects/ar/trunk/test/tc/extract-liblong/extract-liblong.sh
projects/ar/trunk/test/tc/extract-liblong/in/
projects/ar/trunk/test/tc/extract-liblong/in/extract-liblong.in.shar
projects/ar/trunk/test/tc/extract-liblong/out/
projects/ar/trunk/test/tc/extract-liblong/out/extract-liblong.out.shar
projects/ar/trunk/test/tc/extract-libmix-v/
projects/ar/trunk/test/tc/extract-libmix-v/extract-libmix-v.err
projects/ar/trunk/test/tc/extract-libmix-v/extract-libmix-v.eval
projects/ar/trunk/test/tc/extract-libmix-v/extract-libmix-v.out
projects/ar/trunk/test/tc/extract-libmix-v/extract-libmix-v.sh
projects/ar/trunk/test/tc/extract-libmix-v/in/
projects/ar/trunk/test/tc/extract-libmix-v/in/extract-libmix-v.in.shar
projects/ar/trunk/test/tc/extract-libmix-v/out/
projects/ar/trunk/test/tc/extract-libmix-v/out/extract-libmix-v.out.shar
projects/ar/trunk/test/tc/extract-libnonelf-v/
projects/ar/trunk/test/tc/extract-libnonelf-v/extract-libnonelf-v.err
projects/ar/trunk/test/tc/extract-libnonelf-v/extract-libnonelf-v.eval
projects/ar/trunk/test/tc/extract-libnonelf-v/extract-libnonelf-v.out
projects/ar/trunk/test/tc/extract-libnonelf-v/extract-libnonelf-v.sh
projects/ar/trunk/test/tc/extract-libnonelf-v/in/
projects/ar/trunk/test/tc/extract-libnonelf-v/in/extract-libnonelf-v.in.shar
projects/ar/trunk/test/tc/extract-libnonelf-v/out/
projects/ar/trunk/test/tc/extract-libnonelf-v/out/extract-libnonelf-v.out.shar
projects/ar/trunk/test/tc/list-lib65536/
projects/ar/trunk/test/tc/list-lib65536/in/
projects/ar/trunk/test/tc/list-lib65536/in/list-lib65536.in.shar
projects/ar/trunk/test/tc/list-lib65536/list-lib65536.err
projects/ar/trunk/test/tc/list-lib65536/list-lib65536.eval
projects/ar/trunk/test/tc/list-lib65536/list-lib65536.out
projects/ar/trunk/test/tc/list-lib65536/list-lib65536.sh
projects/ar/trunk/test/tc/list-lib65536/out/
projects/ar/trunk/test/tc/list-lib65536/out/list-lib65536.out.shar
projects/ar/trunk/test/tc/list-liblong/
projects/ar/trunk/test/tc/list-liblong/in/
projects/ar/trunk/test/tc/list-liblong/in/list-liblong.in.shar
projects/ar/trunk/test/tc/list-liblong/list-liblong.err
projects/ar/trunk/test/tc/list-liblong/list-liblong.eval
projects/ar/trunk/test/tc/list-liblong/list-liblong.out
projects/ar/trunk/test/tc/list-liblong/list-liblong.sh
projects/ar/trunk/test/tc/list-liblong/out/
projects/ar/trunk/test/tc/list-liblong/out/list-liblong.out.shar
projects/ar/trunk/test/tc/list_s-libaS/
projects/ar/trunk/test/tc/list_s-libaS/in/
projects/ar/trunk/test/tc/list_s-libaS/in/list_s-libaS.in.shar
projects/ar/trunk/test/tc/list_s-libaS/list_s-libaS.err
projects/ar/trunk/test/tc/list_s-libaS/list_s-libaS.eval
projects/ar/trunk/test/tc/list_s-libaS/list_s-libaS.out
projects/ar/trunk/test/tc/list_s-libaS/list_s-libaS.sh
projects/ar/trunk/test/tc/list_s-libaS/out/
projects/ar/trunk/test/tc/list_s-libaS/out/list_s-libaS.out.shar
projects/ar/trunk/test/tc/moveafter-liba-v/
projects/ar/trunk/test/tc/moveafter-liba-v/in/
projects/ar/trunk/test/tc/moveafter-liba-v/in/moveafter-liba-v.in.shar
projects/ar/trunk/test/tc/moveafter-liba-v/moveafter-liba-v.err
projects/ar/trunk/test/tc/moveafter-liba-v/moveafter-liba-v.eval
projects/ar/trunk/test/tc/moveafter-liba-v/moveafter-liba-v.out
projects/ar/trunk/test/tc/moveafter-liba-v/moveafter-liba-v.sh
projects/ar/trunk/test/tc/moveafter-liba-v/out/
projects/ar/trunk/test/tc/moveafter-liba-v/out/moveafter-liba-v.out.shar
projects/ar/trunk/test/tc/moveafter-libmix-v/
projects/ar/trunk/test/tc/moveafter-libmix-v/in/
projects/ar/trunk/test/tc/moveafter-libmix-v/in/moveafter-libmix-v.in.shar
projects/ar/trunk/test/tc/moveafter-libmix-v/moveafter-libmix-v.err
projects/ar/trunk/test/tc/moveafter-libmix-v/moveafter-libmix-v.eval
projects/ar/trunk/test/tc/moveafter-libmix-v/moveafter-libmix-v.out
projects/ar/trunk/test/tc/moveafter-libmix-v/moveafter-libmix-v.sh
projects/ar/trunk/test/tc/moveafter-libmix-v/out/
projects/ar/trunk/test/tc/moveafter-libmix-v/out/moveafter-libmix-v.out.shar
projects/ar/trunk/test/tc/moveafter_movepos-liba-v/
projects/ar/trunk/test/tc/moveafter_movepos-liba-v/in/
projects/ar/trunk/test/tc/moveafter_movepos-liba-v/in/moveafter_movepos-liba-v.in.shar
projects/ar/trunk/test/tc/moveafter_movepos-liba-v/moveafter_movepos-liba-v.err
projects/ar/trunk/test/tc/moveafter_movepos-liba-v/moveafter_movepos-liba-v.eval
projects/ar/trunk/test/tc/moveafter_movepos-liba-v/moveafter_movepos-liba-v.out
projects/ar/trunk/test/tc/moveafter_movepos-liba-v/moveafter_movepos-liba-v.sh
projects/ar/trunk/test/tc/moveafter_movepos-liba-v/out/
projects/ar/trunk/test/tc/moveafter_movepos-liba-v/out/moveafter_movepos-liba-v.out.shar
projects/ar/trunk/test/tc/movebefore-liba-v/
projects/ar/trunk/test/tc/movebefore-liba-v/in/
projects/ar/trunk/test/tc/movebefore-liba-v/in/movebefore-liba-v.in.shar
projects/ar/trunk/test/tc/movebefore-liba-v/movebefore-liba-v.err
projects/ar/trunk/test/tc/movebefore-liba-v/movebefore-liba-v.eval
projects/ar/trunk/test/tc/movebefore-liba-v/movebefore-liba-v.out
projects/ar/trunk/test/tc/movebefore-liba-v/movebefore-liba-v.sh
projects/ar/trunk/test/tc/movebefore-liba-v/out/
projects/ar/trunk/test/tc/movebefore-liba-v/out/movebefore-liba-v.out.shar
projects/ar/trunk/test/tc/movebefore-libmix/
projects/ar/trunk/test/tc/movebefore-libmix/in/
projects/ar/trunk/test/tc/movebefore-libmix/in/movebefore-libmix.in.shar
projects/ar/trunk/test/tc/movebefore-libmix/movebefore-libmix.err
projects/ar/trunk/test/tc/movebefore-libmix/movebefore-libmix.eval
projects/ar/trunk/test/tc/movebefore-libmix/movebefore-libmix.out
projects/ar/trunk/test/tc/movebefore-libmix/movebefore-libmix.sh
projects/ar/trunk/test/tc/movebefore-libmix/out/
projects/ar/trunk/test/tc/movebefore-libmix/out/movebefore-libmix.out.shar
projects/ar/trunk/test/tc/movebefore_movepos-liba-v/
projects/ar/trunk/test/tc/movebefore_movepos-liba-v/in/
projects/ar/trunk/test/tc/movebefore_movepos-liba-v/in/movebefore_movepos-liba-v.in.shar
projects/ar/trunk/test/tc/movebefore_movepos-liba-v/movebefore_movepos-liba-v.err
projects/ar/trunk/test/tc/movebefore_movepos-liba-v/movebefore_movepos-liba-v.eval
projects/ar/trunk/test/tc/movebefore_movepos-liba-v/movebefore_movepos-liba-v.out
projects/ar/trunk/test/tc/movebefore_movepos-liba-v/movebefore_movepos-liba-v.sh
projects/ar/trunk/test/tc/movebefore_movepos-liba-v/out/
projects/ar/trunk/test/tc/movebefore_movepos-liba-v/out/movebefore_movepos-liba-v.out.shar
projects/ar/trunk/test/tc/movetail-libmix/
projects/ar/trunk/test/tc/movetail-libmix/in/
projects/ar/trunk/test/tc/movetail-libmix/in/movetail-libmix.in.shar
projects/ar/trunk/test/tc/movetail-libmix/movetail-libmix.err
projects/ar/trunk/test/tc/movetail-libmix/movetail-libmix.eval
projects/ar/trunk/test/tc/movetail-libmix/movetail-libmix.out
projects/ar/trunk/test/tc/movetail-libmix/movetail-libmix.sh
projects/ar/trunk/test/tc/movetail-libmix/out/
projects/ar/trunk/test/tc/movetail-libmix/out/movetail-libmix.out.shar
projects/ar/trunk/test/tc/optionl-liba/
projects/ar/trunk/test/tc/optionl-liba/in/
projects/ar/trunk/test/tc/optionl-liba/in/optionl-liba.in.shar
projects/ar/trunk/test/tc/optionl-liba/optionl-liba.err
projects/ar/trunk/test/tc/optionl-liba/optionl-liba.eval
projects/ar/trunk/test/tc/optionl-liba/optionl-liba.out
projects/ar/trunk/test/tc/optionl-liba/optionl-liba.sh
projects/ar/trunk/test/tc/optionl-liba/out/
projects/ar/trunk/test/tc/optionl-liba/out/optionl-liba.out.shar
projects/ar/trunk/test/tc/print-liblong/
projects/ar/trunk/test/tc/print-liblong/in/
projects/ar/trunk/test/tc/print-liblong/in/print-liblong.in.shar
projects/ar/trunk/test/tc/print-liblong/out/
projects/ar/trunk/test/tc/print-liblong/out/print-liblong.out.shar
projects/ar/trunk/test/tc/print-liblong/print-liblong.err
projects/ar/trunk/test/tc/print-liblong/print-liblong.eval
projects/ar/trunk/test/tc/print-liblong/print-liblong.out
projects/ar/trunk/test/tc/print-liblong/print-liblong.sh
projects/ar/trunk/test/tc/print-liblong-v/
projects/ar/trunk/test/tc/print-liblong-v/in/
projects/ar/trunk/test/tc/print-liblong-v/in/print-liblong-v.in.shar
projects/ar/trunk/test/tc/print-liblong-v/out/
projects/ar/trunk/test/tc/print-liblong-v/out/print-liblong-v.out.shar
projects/ar/trunk/test/tc/print-liblong-v/print-liblong-v.err
projects/ar/trunk/test/tc/print-liblong-v/print-liblong-v.eval
projects/ar/trunk/test/tc/print-liblong-v/print-liblong-v.out
projects/ar/trunk/test/tc/print-liblong-v/print-liblong-v.sh
projects/ar/trunk/test/tc/print-libmix/
projects/ar/trunk/test/tc/print-libmix/in/
projects/ar/trunk/test/tc/print-libmix/in/print-libmix.in.shar
projects/ar/trunk/test/tc/print-libmix/out/
projects/ar/trunk/test/tc/print-libmix/out/print-libmix.out.shar
projects/ar/trunk/test/tc/print-libmix/print-libmix.err
projects/ar/trunk/test/tc/print-libmix/print-libmix.eval
projects/ar/trunk/test/tc/print-libmix/print-libmix.out
projects/ar/trunk/test/tc/print-libmix/print-libmix.sh
projects/ar/trunk/test/tc/print-libmix-v/
projects/ar/trunk/test/tc/print-libmix-v/in/
projects/ar/trunk/test/tc/print-libmix-v/in/print-libmix-v.in.shar
projects/ar/trunk/test/tc/print-libmix-v/out/
projects/ar/trunk/test/tc/print-libmix-v/out/print-libmix-v.out.shar
projects/ar/trunk/test/tc/print-libmix-v/print-libmix-v.err
projects/ar/trunk/test/tc/print-libmix-v/print-libmix-v.eval
projects/ar/trunk/test/tc/print-libmix-v/print-libmix-v.out
projects/ar/trunk/test/tc/print-libmix-v/print-libmix-v.sh
projects/ar/trunk/test/tc/quickadd-liba-v/
projects/ar/trunk/test/tc/quickadd-liba-v/in/
projects/ar/trunk/test/tc/quickadd-liba-v/in/quickadd-liba-v.in.shar
projects/ar/trunk/test/tc/quickadd-liba-v/out/
projects/ar/trunk/test/tc/quickadd-liba-v/out/quickadd-liba-v.out.shar
projects/ar/trunk/test/tc/quickadd-liba-v/quickadd-liba-v.err
projects/ar/trunk/test/tc/quickadd-liba-v/quickadd-liba-v.eval
projects/ar/trunk/test/tc/quickadd-liba-v/quickadd-liba-v.out
projects/ar/trunk/test/tc/quickadd-liba-v/quickadd-liba-v.sh
projects/ar/trunk/test/tc/undefined-libsbrk/
projects/ar/trunk/test/tc/undefined-libsbrk/in/
projects/ar/trunk/test/tc/undefined-libsbrk/in/undefined-libsbrk.in.shar
projects/ar/trunk/test/tc/undefined-libsbrk/out/
projects/ar/trunk/test/tc/undefined-libsbrk/out/undefined-libsbrk.out.shar
projects/ar/trunk/test/tc/undefined-libsbrk/undefined-libsbrk.err
projects/ar/trunk/test/tc/undefined-libsbrk/undefined-libsbrk.eval
projects/ar/trunk/test/tc/undefined-libsbrk/undefined-libsbrk.out
projects/ar/trunk/test/tc/undefined-libsbrk/undefined-libsbrk.sh
projects/ar/trunk/test/tc/usage-ab/
projects/ar/trunk/test/tc/usage-ab/usage-ab.err
projects/ar/trunk/test/tc/usage-ab/usage-ab.eval
projects/ar/trunk/test/tc/usage-ab/usage-ab.out
projects/ar/trunk/test/tc/usage-ab/usage-ab.sh
projects/ar/trunk/test/tc/usage-bi/
projects/ar/trunk/test/tc/usage-bi/usage-bi.err
projects/ar/trunk/test/tc/usage-bi/usage-bi.eval
projects/ar/trunk/test/tc/usage-bi/usage-bi.out
projects/ar/trunk/test/tc/usage-bi/usage-bi.sh
projects/ar/trunk/test/tc/usage-tx/
projects/ar/trunk/test/tc/usage-tx/usage-tx.err
projects/ar/trunk/test/tc/usage-tx/usage-tx.eval
projects/ar/trunk/test/tc/usage-tx/usage-tx.out
projects/ar/trunk/test/tc/usage-tx/usage-tx.sh
projects/ar/trunk/test/tc/weaksymbol-libweak/
projects/ar/trunk/test/tc/weaksymbol-libweak/in/
projects/ar/trunk/test/tc/weaksymbol-libweak/in/weaksymbol-libweak.in.shar
projects/ar/trunk/test/tc/weaksymbol-libweak/out/
projects/ar/trunk/test/tc/weaksymbol-libweak/out/weaksymbol-libweak.out.shar
projects/ar/trunk/test/tc/weaksymbol-libweak/weaksymbol-libweak.err
projects/ar/trunk/test/tc/weaksymbol-libweak/weaksymbol-libweak.eval
projects/ar/trunk/test/tc/weaksymbol-libweak/weaksymbol-libweak.out
projects/ar/trunk/test/tc/weaksymbol-libweak/weaksymbol-libweak.sh
projects/ar/trunk/test/tcgen.sh
projects/ar/trunk/util.c
projects/ar/trunk/write.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jk...@us...> - 2008-04-02 10:38:42
|
Revision: 5
http://elftoolchain.svn.sourceforge.net/elftoolchain/?rev=5&view=rev
Author: jkoshy
Date: 2008-04-02 03:38:36 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Import a snapshot of libelf from FreeBSD's CVS.
Added Paths:
-----------
projects/libelf/trunk/Makefile
projects/libelf/trunk/Version.map
projects/libelf/trunk/_libelf.h
projects/libelf/trunk/elf.3
projects/libelf/trunk/elf_begin.3
projects/libelf/trunk/elf_begin.c
projects/libelf/trunk/elf_cntl.3
projects/libelf/trunk/elf_cntl.c
projects/libelf/trunk/elf_data.c
projects/libelf/trunk/elf_end.3
projects/libelf/trunk/elf_end.c
projects/libelf/trunk/elf_errmsg.3
projects/libelf/trunk/elf_errmsg.c
projects/libelf/trunk/elf_errno.c
projects/libelf/trunk/elf_fill.3
projects/libelf/trunk/elf_fill.c
projects/libelf/trunk/elf_flag.c
projects/libelf/trunk/elf_flagdata.3
projects/libelf/trunk/elf_getarhdr.3
projects/libelf/trunk/elf_getarhdr.c
projects/libelf/trunk/elf_getarsym.3
projects/libelf/trunk/elf_getarsym.c
projects/libelf/trunk/elf_getbase.3
projects/libelf/trunk/elf_getbase.c
projects/libelf/trunk/elf_getdata.3
projects/libelf/trunk/elf_getident.3
projects/libelf/trunk/elf_getident.c
projects/libelf/trunk/elf_getphnum.3
projects/libelf/trunk/elf_getscn.3
projects/libelf/trunk/elf_getshnum.3
projects/libelf/trunk/elf_getshstrndx.3
projects/libelf/trunk/elf_hash.3
projects/libelf/trunk/elf_hash.c
projects/libelf/trunk/elf_kind.3
projects/libelf/trunk/elf_kind.c
projects/libelf/trunk/elf_memory.3
projects/libelf/trunk/elf_memory.c
projects/libelf/trunk/elf_next.3
projects/libelf/trunk/elf_next.c
projects/libelf/trunk/elf_phnum.c
projects/libelf/trunk/elf_rand.3
projects/libelf/trunk/elf_rand.c
projects/libelf/trunk/elf_rawfile.3
projects/libelf/trunk/elf_rawfile.c
projects/libelf/trunk/elf_scn.c
projects/libelf/trunk/elf_shnum.c
projects/libelf/trunk/elf_shstrndx.c
projects/libelf/trunk/elf_strptr.3
projects/libelf/trunk/elf_strptr.c
projects/libelf/trunk/elf_types.m4
projects/libelf/trunk/elf_update.3
projects/libelf/trunk/elf_update.c
projects/libelf/trunk/elf_version.3
projects/libelf/trunk/elf_version.c
projects/libelf/trunk/gelf.3
projects/libelf/trunk/gelf.h
projects/libelf/trunk/gelf_cap.c
projects/libelf/trunk/gelf_checksum.3
projects/libelf/trunk/gelf_checksum.c
projects/libelf/trunk/gelf_dyn.c
projects/libelf/trunk/gelf_ehdr.c
projects/libelf/trunk/gelf_fsize.3
projects/libelf/trunk/gelf_fsize.c
projects/libelf/trunk/gelf_getcap.3
projects/libelf/trunk/gelf_getclass.3
projects/libelf/trunk/gelf_getclass.c
projects/libelf/trunk/gelf_getdyn.3
projects/libelf/trunk/gelf_getehdr.3
projects/libelf/trunk/gelf_getmove.3
projects/libelf/trunk/gelf_getphdr.3
projects/libelf/trunk/gelf_getrel.3
projects/libelf/trunk/gelf_getrela.3
projects/libelf/trunk/gelf_getshdr.3
projects/libelf/trunk/gelf_getsym.3
projects/libelf/trunk/gelf_getsyminfo.3
projects/libelf/trunk/gelf_getsymshndx.3
projects/libelf/trunk/gelf_move.c
projects/libelf/trunk/gelf_newehdr.3
projects/libelf/trunk/gelf_newphdr.3
projects/libelf/trunk/gelf_phdr.c
projects/libelf/trunk/gelf_rel.c
projects/libelf/trunk/gelf_rela.c
projects/libelf/trunk/gelf_shdr.c
projects/libelf/trunk/gelf_sym.c
projects/libelf/trunk/gelf_syminfo.c
projects/libelf/trunk/gelf_symshndx.c
projects/libelf/trunk/gelf_update_ehdr.3
projects/libelf/trunk/gelf_xlate.c
projects/libelf/trunk/gelf_xlatetof.3
projects/libelf/trunk/libelf.c
projects/libelf/trunk/libelf.h
projects/libelf/trunk/libelf_align.c
projects/libelf/trunk/libelf_allocate.c
projects/libelf/trunk/libelf_ar.c
projects/libelf/trunk/libelf_checksum.c
projects/libelf/trunk/libelf_convert.m4
projects/libelf/trunk/libelf_data.c
projects/libelf/trunk/libelf_ehdr.c
projects/libelf/trunk/libelf_extended.c
projects/libelf/trunk/libelf_fsize.m4
projects/libelf/trunk/libelf_msize.m4
projects/libelf/trunk/libelf_phdr.c
projects/libelf/trunk/libelf_shdr.c
projects/libelf/trunk/libelf_xlate.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jk...@us...> - 2008-04-02 09:46:35
|
Revision: 4
http://elftoolchain.svn.sourceforge.net/elftoolchain/?rev=4&view=rev
Author: jkoshy
Date: 2008-04-02 02:46:30 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Add an implementation of size(1) contributed by Sam Arun Raj.
Added Paths:
-----------
projects/size/trunk/Makefile
projects/size/trunk/size.1
projects/size/trunk/size.c
Added: projects/size/trunk/Makefile
===================================================================
--- projects/size/trunk/Makefile (rev 0)
+++ projects/size/trunk/Makefile 2008-04-02 09:46:30 UTC (rev 4)
@@ -0,0 +1,8 @@
+#
+
+PROG= size
+WARNS?= 6
+LDADD= -lelf
+
+.include <bsd.prog.mk>
+
Added: projects/size/trunk/size.1
===================================================================
--- projects/size/trunk/size.1 (rev 0)
+++ projects/size/trunk/size.1 2008-04-02 09:46:30 UTC (rev 4)
@@ -0,0 +1,132 @@
+.\" Copyright (c) 2007 S.Sam Arun Raj
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd March 25, 2007
+.Dt SIZE 1
+.Os
+.Sh NAME
+.Nm size
+.Nd "display section sizes and total size in"
+.Tn ELF
+files.
+.Sh SYNOPSIS
+.Nm
+.Op Fl Adhotx
+.Op Ar
+.Sh DESCRIPTION
+The
+.Nm
+utility
+lists the size of various sections and total size (if choosen) for each input
+.Ar file.
+The
+.Nm
+utility can operate on ELF object,
+.Xr ar 1
+archives, and core dumps.
+.Pp
+If no file name is specified in the input, "a.out" is assumed.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl A
+The output of
+.Nm
+will resemble output from System V
+.Nm .
+By default, one line of output is generated for each ELF object or each module
+in an archive, if this option is not choosen.
+.It Fl t
+Shows cumulative totals of section sizes from all objects. Not available when
+System V output format
+.Fl A
+is choosen.
+.It Fl d | Fl o | Fl x
+The section sizes can be displayed either in decimal, octal or hexadecimal by
+choosing one of these options. Totals
+.Fl t
+are always displayed in two radixes; decimal and hexadecimal for
+.Fl d
+or
+.Fl x
+output, or octal and hexadecimal if
+.Fl o
+is choosen.
+.It Fl h
+This prints a usage summary and exits.
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh EXAMPLES
+The following are examples of typical usage
+of the
+.Nm
+command:
+.Pp
+.Dl "$ size /bin/ls"
+.Dl "text data bss dec hex filename"
+.Dl "20975 540 392 21907 5593 /bin/ls"
+.Pp
+.Dl "$ size -tx /bin/ls /bin/dd"
+.Dl "text data bss dec hex filename"
+.Dl "0x51ef 0x21c 0x188 21907 5593 /bin/ls"
+.Dl "0x3df5 0x170 0x200 16741 4165 /bin/dd"
+.Dl "0x8fe4 0x38c 0x388 38648 96f8 (TOTALS)"
+.Sh SEE ALSO
+.Xr ar 1 ,
+.Xr objdump 1 ,
+.Xr readelf 1
+.Rs
+.%A "AT&T Unix Systems Labs"
+.%T "System V Application Binary Interface"
+.%O http://www.sco.com/developers/gabi/
+.Re
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.At v6.
+The last FreeBSD
+.Nm
+was discontinued in
+.Fx v5 ,
+when i386-only a.out format was dropped in favor of ELF.
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+utility was re-written by
+.An S.Sam Arun Raj Aq sam...@gm...
+This manual page was written by
+.An S.Sam Arun Raj Aq sam...@gm...
+.Sh LIMITATIONS
+Unlike the GNU
+.Nm
+this doesn't support multiple object file formats, only ELF using the
+.Xr elf 3
+and
+.Xr gelf 3
+API's.
Added: projects/size/trunk/size.c
===================================================================
--- projects/size/trunk/size.c (rev 0)
+++ projects/size/trunk/size.c 2008-04-02 09:46:30 UTC (rev 4)
@@ -0,0 +1,762 @@
+/*-
+ * Copyright (c) 2007 S.Sam Arun Raj
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <err.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#include <libelf.h>
+#include <gelf.h>
+
+#define BUF_SIZE 40
+#define ELF_ALIGN(val,x) \
+ (((val) + (x) - 1) > (val) ? (((val)+(x)-1) & ~((x)-1)) : ~0)
+
+#ifndef NT_AUXV
+#define NT_AUXV 6
+#endif
+#ifndef NT_LWPSTATUS
+#define NT_LWPSTATUS 16
+#endif
+#ifndef NT_PRFPREG
+#define NT_PRFPREG 2
+#endif
+#ifndef NT_PSTATUS
+#define NT_PSTATUS 10
+#endif
+#ifndef NT_PSINFO
+#define NT_PSINFO 13
+#endif
+#ifndef NT_PRXFPREG
+#define NT_PRXFPREG 0x46e62b7f
+#endif
+#ifndef PT_GNU_EH_FRAME
+#define PT_GNU_EH_FRAME (PT_LOOS + 0x474e550)
+#endif
+#ifndef PT_GNU_STACK
+#define PT_GNU_STACK (PT_LOOS + 0x474e551)
+#endif
+
+enum output_style {
+ STYLE_BERKELEY,
+ STYLE_SYSV
+};
+
+enum radix_style {
+ RADIX_OCTAL,
+ RADIX_DECIMAL,
+ RADIX_HEX
+};
+
+size_t sec_name_len;
+uint32_t bss_size_total, data_size_total, text_size_total;
+uint32_t bss_size, data_size, text_size, total_size;
+int show_totals;
+enum radix_style radix;
+enum output_style style;
+const char default_name[] = "a.out";
+
+int handle_elf(char const *);
+int handle_core(char const *, Elf *elf, GElf_Ehdr *);
+void handle_core_note(Elf *, GElf_Ehdr *, GElf_Phdr *, char **);
+void handle_phdr(Elf *, GElf_Ehdr *, GElf_Phdr *, uint32_t,
+ const char *);
+void usage(void);
+void print_number(int, uint32_t, enum radix_style, char);
+void berkeley_header(void);
+void berkeley_footer(const char *, const char *, const char *);
+void berkeley_calc(GElf_Shdr *);
+void berkeley_totals(void);
+void sysv_header(const char *, Elf_Arhdr *);
+void sysv_footer(void);
+void sysv_calc(Elf *, GElf_Ehdr *, GElf_Shdr *, int);
+
+/*
+ * size utility using elf(3) and gelf(3) API to list section sizes and
+ * total in elf files. Supports only elf files (core dumps in elf
+ * included) that can be opened by libelf, other formats are not supported.
+ */
+int
+main(int argc, char *argv[])
+{
+ int ch, exit_code;
+
+ sec_name_len = 19;
+ exit_code = EX_OK;
+ style = STYLE_BERKELEY;
+ radix = RADIX_DECIMAL;
+ if (elf_version(EV_CURRENT) == EV_NONE)
+ errx(EX_SOFTWARE, "ELF library initialization failed: %s",
+ elf_errmsg(-1));
+
+ while ((ch = getopt(argc, argv, "Adhotx")) != -1)
+ switch((char)ch) {
+ case 'A':
+ style = STYLE_SYSV;
+ break;
+ case 'd':
+ radix = RADIX_DECIMAL;
+ break;
+ case 't':
+ show_totals = 1;
+ break;
+ case 'o':
+ radix = RADIX_OCTAL;
+ break;
+ case 'x':
+ radix = RADIX_HEX;
+ break;
+ case 'h':
+ case '?':
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (!*argv) {
+ exit_code = handle_elf(default_name);
+ if (exit_code == EX_SOFTWARE || exit_code == EX_DATAERR)
+ warnx("%s: File format not recognized", default_name);
+ if (exit_code == EX_NOINPUT)
+ warnx("'%s': No such file", default_name);
+ }
+ else while (*argv) {
+ exit_code = handle_elf(*argv);
+ if (exit_code == EX_SOFTWARE || exit_code == EX_DATAERR)
+ warnx("%s: File format not recognized", *argv);
+ if (exit_code == EX_NOINPUT)
+ warnx("'%s': No such file", *argv);
+ argv++;
+ }
+ if (style == STYLE_BERKELEY)
+ berkeley_totals();
+ return (exit_code);
+}
+
+static Elf_Data *
+xlatetom(Elf *elf, GElf_Ehdr *elfhdr, void *_src, void *_dst,
+ Elf_Type type, size_t size)
+{
+ Elf_Data src, dst;
+
+ src.d_buf = _src;
+ src.d_type = type;
+ src.d_version = elfhdr->e_version;
+ src.d_size = size;
+ dst.d_buf = _dst;
+ dst.d_version = elfhdr->e_version;
+ dst.d_size = size;
+ return gelf_xlatetom(elf, &dst, &src, elfhdr->e_ident[EI_DATA]);
+}
+
+#define NOTE_OFFSET_32(nhdr, namesz, offset) \
+ ((char *)nhdr + sizeof(Elf32_Nhdr) + \
+ ELF_ALIGN((int32_t)namesz, 4) + offset)
+
+#define NOTE_OFFSET_64(nhdr, namesz, offset) \
+ ((char *)nhdr + sizeof(Elf32_Nhdr) + \
+ ELF_ALIGN((int32_t)namesz, 8) + offset)
+
+#define PID32(nhdr, namesz, offset) \
+ (pid_t)*((int *)((uintptr_t)NOTE_OFFSET_32(nhdr, \
+ namesz, offset)));
+
+#define PID64(nhdr, namesz, offset) \
+ (pid_t)*((int *)((uintptr_t)NOTE_OFFSET_64(nhdr, \
+ namesz, offset)));
+
+#define NEXT_NOTE(elfhdr, descsz, namesz, offset) do { \
+ if (elfhdr->e_ident[EI_CLASS] == ELFCLASS32) { \
+ offset += ELF_ALIGN((int32_t)descsz, 4) + \
+ sizeof(Elf32_Nhdr) + \
+ ELF_ALIGN((int32_t)namesz, 4); \
+ } else { \
+ offset += ELF_ALIGN((int32_t)descsz, 8) + \
+ sizeof(Elf32_Nhdr) + \
+ ELF_ALIGN((int32_t)namesz, 8); \
+ } \
+} while (0)
+
+/*
+ * Parse individual note entries inside a PT_NOTE segment.
+ */
+void
+handle_core_note(Elf *elf, GElf_Ehdr *elfhdr, GElf_Phdr *phdr,
+ char **cmd_line)
+{
+ size_t max_size;
+ uint64_t raw_size;
+ GElf_Off offset;
+ static pid_t pid;
+ uintptr_t ver;
+ Elf32_Nhdr *nhdr, nhdr_l;
+ static int reg_pseudo = 0, reg2_pseudo = 0, regxfp_pseudo = 0;
+ char buf[BUF_SIZE], *data, *name;
+
+ if (elf == NULL || elfhdr == NULL || phdr == NULL)
+ return;
+
+ data = elf_rawfile(elf, &max_size);
+ offset = phdr->p_offset;
+ while (data != NULL && offset < phdr->p_offset + phdr->p_filesz) {
+ nhdr = (Elf32_Nhdr *)(uintptr_t)((char*)data + offset);
+ memset(&nhdr_l, 0, sizeof(Elf32_Nhdr));
+ if (!xlatetom(elf, elfhdr, &nhdr->n_type, &nhdr_l.n_type,
+ ELF_T_WORD, sizeof(Elf32_Word)) ||
+ !xlatetom(elf, elfhdr, &nhdr->n_descsz, &nhdr_l.n_descsz,
+ ELF_T_WORD, sizeof(Elf32_Word)) ||
+ !xlatetom(elf, elfhdr, &nhdr->n_namesz, &nhdr_l.n_namesz,
+ ELF_T_WORD, sizeof(Elf32_Word)))
+ break;
+
+ name = (char *)((char *)nhdr + sizeof(Elf32_Nhdr));
+ switch (nhdr_l.n_type) {
+ case NT_PRSTATUS: {
+ raw_size = 0;
+ if (elfhdr->e_ident[EI_OSABI] == ELFOSABI_FREEBSD &&
+ nhdr_l.n_namesz == 0x8 &&
+ !strcmp(name,"FreeBSD")) {
+ if (elfhdr->e_ident[EI_CLASS] == ELFCLASS32) {
+ raw_size = (uint64_t)*((uint32_t *)
+ (uintptr_t)(name +
+ ELF_ALIGN((int32_t)
+ nhdr_l.n_namesz, 4) + 8));
+ ver = (uintptr_t)NOTE_OFFSET_32(nhdr,
+ nhdr_l.n_namesz,0);
+ if (*((int *)ver) == 1)
+ pid = PID32(nhdr,
+ nhdr_l.n_namesz, 24);
+ } else {
+ raw_size = *((uint64_t *)(uintptr_t)
+ (name + ELF_ALIGN((int32_t)
+ nhdr_l.n_namesz, 8) + 16));
+ ver = (uintptr_t)NOTE_OFFSET_64(nhdr,
+ nhdr_l.n_namesz,0);
+ if (*((int *)ver) == 1)
+ pid = PID64(nhdr,
+ nhdr_l.n_namesz, 40);
+ }
+ xlatetom(elf, elfhdr, &raw_size, &raw_size,
+ ELF_T_WORD, sizeof(uint64_t));
+ xlatetom(elf, elfhdr, &pid, &pid, ELF_T_WORD,
+ sizeof(pid_t));
+ }
+
+ if (raw_size != 0 && style == STYLE_SYSV) {
+ (void) snprintf(buf, BUF_SIZE, "%s/%d",
+ ".reg", pid);
+ (void) printf("%-18s ", buf);
+ print_number(10, (uint32_t)raw_size,
+ radix, ' ');
+ print_number(10, (uint32_t)0,
+ radix, '\n');
+ if (!reg_pseudo) {
+ (void) printf("%-18s ", ".reg");
+ print_number(10, (uint32_t)raw_size,
+ radix, ' ');
+ print_number(10, (uint32_t)0, radix,
+ '\n');
+ reg_pseudo = 1;
+ text_size_total += raw_size;
+ }
+ text_size_total += raw_size;
+ }
+ }
+ break;
+ case NT_PRFPREG: /* same as NT_FPREGSET */
+ if (style == STYLE_SYSV) {
+ (void) snprintf(buf, BUF_SIZE,
+ "%s/%d", ".reg2", pid);
+ (void) printf("%-18s ", buf);
+ print_number(10, (uint32_t)nhdr_l.n_descsz,
+ radix, ' ');
+ print_number(10, (uint32_t)0, radix, '\n');
+ if (!reg2_pseudo) {
+ (void) printf("%-18s ", ".reg2");
+ print_number(10,
+ (uint32_t)nhdr_l.n_descsz,
+ radix, ' ');
+ print_number(10, (uint32_t)0, radix,
+ '\n');
+ reg2_pseudo = 1;
+ text_size_total += nhdr_l.n_descsz;
+ }
+ text_size_total += nhdr_l.n_descsz;
+ }
+ break;
+ case NT_AUXV:
+ if (style == STYLE_SYSV) {
+ (void) printf("%-18s ", ".auxv");
+ print_number(10, (uint32_t)nhdr_l.n_descsz,
+ radix, ' ');
+ print_number(10, (uint32_t)0, radix, '\n');
+ text_size_total += nhdr_l.n_descsz;
+ }
+ break;
+ case NT_PRXFPREG:
+ if (style == STYLE_SYSV) {
+ (void) snprintf(buf, BUF_SIZE,
+ "%s/%d", ".reg-xfp", pid);
+ (void) printf("%-18s ", buf);
+ print_number(10, (uint32_t)nhdr_l.n_descsz,
+ radix, ' ');
+ print_number(10, (uint32_t)0, radix, '\n');
+ if (!regxfp_pseudo) {
+ (void) printf("%-18s ", ".reg-xfp");
+ print_number(10,
+ (uint32_t)nhdr_l.n_descsz,
+ radix, ' ');
+ print_number(10, (uint32_t)0,
+ radix, '\n');
+ regxfp_pseudo = 1;
+ text_size_total += nhdr_l.n_descsz;
+ }
+ text_size_total += nhdr_l.n_descsz;
+ }
+ break;
+ case NT_PSINFO:
+ case NT_PRPSINFO: {
+ /* FreeBSD 64-bit */
+ if (nhdr_l.n_descsz == 0x78 &&
+ !strcmp(name,"FreeBSD")) {
+ *cmd_line = strdup(NOTE_OFFSET_64(nhdr,
+ nhdr_l.n_namesz, 33));
+ /* FreeBSD 32-bit */
+ } else if (nhdr_l.n_descsz == 0x6c &&
+ !strcmp(name,"FreeBSD")) {
+ *cmd_line = strdup(NOTE_OFFSET_32(nhdr,
+ nhdr_l.n_namesz, 25));
+ }
+ /* Strip any trailing spaces */
+ if (*cmd_line != NULL) {
+ char *s;
+
+ s = *cmd_line + strlen(*cmd_line);
+ while (s > *cmd_line) {
+ if (*(s-1) != 0x20) break;
+ s--;
+ }
+ *s = 0;
+ }
+ break;
+ }
+ case NT_PSTATUS:
+ case NT_LWPSTATUS:
+ default:
+ break;
+ }
+ NEXT_NOTE(elfhdr, nhdr_l.n_descsz, nhdr_l.n_namesz, offset);
+ }
+}
+
+/*
+ * Handles program headers except for PT_NOTE, when sysv output stlye is
+ * choosen, prints out the segment name and length. For berkely output
+ * style only PT_LOAD segments are handled, and text,
+ * data, bss size is calculated for them.
+ */
+void
+handle_phdr(Elf *elf, GElf_Ehdr *elfhdr, GElf_Phdr *phdr,
+ uint32_t idx, const char *name)
+{
+ uint32_t addr, size;
+ int split;
+ char buf[BUF_SIZE];
+
+ if (elf == NULL || elfhdr == NULL || phdr == NULL)
+ return;
+
+ size = addr = 0;
+ split = (phdr->p_memsz > 0) && (phdr->p_filesz > 0) &&
+ (phdr->p_memsz > phdr->p_filesz);
+
+ if (style == STYLE_SYSV) {
+ (void) snprintf(buf, BUF_SIZE,
+ "%s%d%s", name, idx, (split ? "a" : ""));
+ (void) printf("%-18s ", buf);
+ print_number(10, (uint32_t)phdr->p_filesz, radix, ' ');
+ print_number(10, (uint32_t)phdr->p_vaddr, radix, '\n');
+ text_size_total += phdr->p_filesz;
+ if (split) {
+ size = (uint32_t)(phdr->p_memsz - phdr->p_filesz);
+ addr = (uint32_t)(phdr->p_vaddr + phdr->p_filesz);
+ (void) snprintf(buf, BUF_SIZE, "%s%d%s", name,
+ idx, "b");
+ text_size_total += phdr->p_memsz - phdr->p_filesz;
+ (void) printf("%-18s ", buf);
+ print_number(10, size, radix, ' ');
+ print_number(10, addr, radix, '\n');
+ }
+ } else {
+ if (phdr->p_type != PT_LOAD)
+ return;
+ if ((phdr->p_flags & PF_W) && !(phdr->p_flags & PF_X)) {
+ data_size += phdr->p_filesz;
+ if (split)
+ data_size += phdr->p_memsz - phdr->p_filesz;
+ } else {
+ text_size += phdr->p_filesz;
+ if (split)
+ text_size += phdr->p_memsz - phdr->p_filesz;
+ }
+ }
+}
+
+/*
+ * Given a core dump file, this function maps program headers to segments.
+ */
+int
+handle_core(char const *name, Elf *elf, GElf_Ehdr *elfhdr)
+{
+ GElf_Phdr phdr;
+ uint32_t i;
+ char *core_cmdline;
+ const char *seg_name;
+
+ if (name == NULL || elf == NULL || elfhdr == NULL)
+ return (EX_DATAERR);
+ if (elfhdr->e_shnum != 0 || elfhdr->e_type != ET_CORE)
+ return (EX_DATAERR);
+
+ seg_name = core_cmdline = NULL;
+ if (style == STYLE_SYSV)
+ sysv_header(name, NULL);
+ else
+ berkeley_header();
+
+ for (i = 0; i < elfhdr->e_phnum; i++) {
+ if (gelf_getphdr(elf, i, &phdr) != NULL) {
+ if (phdr.p_type == PT_NOTE) {
+ handle_phdr(elf, elfhdr, &phdr, i, "note");
+ handle_core_note(elf, elfhdr, &phdr,
+ &core_cmdline);
+ } else {
+ switch(phdr.p_type) {
+ case PT_NULL:
+ seg_name = "null";
+ break;
+ case PT_LOAD:
+ seg_name = "load";
+ break;
+ case PT_DYNAMIC:
+ seg_name = "dynamic";
+ break;
+ case PT_INTERP:
+ seg_name = "interp";
+ break;
+ case PT_SHLIB:
+ seg_name = "shlib";
+ break;
+ case PT_PHDR:
+ seg_name = "phdr";
+ break;
+ case PT_GNU_EH_FRAME:
+ seg_name = "eh_frame_hdr";
+ break;
+ case PT_GNU_STACK:
+ seg_name = "stack";
+ break;
+ default:
+ seg_name = "segment";
+ }
+ handle_phdr(elf, elfhdr, &phdr, i, seg_name);
+ }
+ }
+ }
+
+ if (style == STYLE_BERKELEY) {
+ if (core_cmdline != NULL) {
+ berkeley_footer(core_cmdline, name,
+ "core file invoked as");
+ } else {
+ berkeley_footer(core_cmdline, name, "core file");
+ }
+ } else {
+ sysv_footer();
+ if (core_cmdline != NULL) {
+ (void) printf(" (core file invoked as %s)\n\n",
+ core_cmdline);
+ } else {
+ (void) printf(" (core file)\n\n");
+ }
+ }
+ free(core_cmdline);
+ return (EX_OK);
+}
+
+/*
+ * Given an elf object,ar(1) filename, and based on the output style
+ * and radix format the various sections and their length will be printed
+ * or the size of the text, data, bss sections will be printed out.
+ */
+int
+handle_elf(char const *name)
+{
+ GElf_Ehdr elfhdr;
+ GElf_Shdr shdr;
+ Elf *elf, *elf1;
+ Elf_Arhdr *arhdr;
+ Elf_Scn *scn;
+ Elf_Cmd elf_cmd;
+ int exit_code, fd;
+
+ if (name == NULL)
+ return (EX_NOINPUT);
+
+ if ((fd = open(name, O_RDONLY, 0)) < 0)
+ return (EX_NOINPUT);
+
+ elf_cmd = ELF_C_READ;
+ elf1 = elf_begin(fd, elf_cmd, NULL);
+ while ((elf = elf_begin(fd, elf_cmd, elf1)) != NULL) {
+ arhdr = elf_getarhdr(elf);
+ if (elf_kind(elf) == ELF_K_NONE && arhdr == NULL) {
+ (void) elf_end(elf);
+ (void) elf_end(elf1);
+ (void) close(fd);
+ return (EX_DATAERR);
+ }
+ if (elf_kind(elf) != ELF_K_ELF ||
+ (gelf_getehdr(elf, &elfhdr) == NULL)) {
+ elf_cmd = elf_next(elf);
+ (void) elf_end(elf);
+ warnx("%s: File format not recognized",
+ arhdr->ar_name);
+ continue;
+ }
+ /* Core dumps are handled seperately */
+ if (elfhdr.e_shnum == 0 && elfhdr.e_type == ET_CORE) {
+ exit_code = handle_core(name, elf, &elfhdr);
+ (void) elf_end(elf);
+ (void) elf_end(elf1);
+ (void) close(fd);
+ return (exit_code);
+ } else {
+ scn = NULL;
+ if (style == STYLE_BERKELEY) {
+ berkeley_header();
+ while ((scn = elf_nextscn(elf, scn)) != NULL) {
+ if (gelf_getshdr(scn, &shdr) != NULL)
+ berkeley_calc(&shdr);
+ }
+ } else {
+ /*
+ * Perform a dry run to find the length of
+ * the largest segment name.
+ */
+ while ((scn = elf_nextscn(elf, scn)) != NULL) {
+ if (gelf_getshdr(scn, &shdr) != NULL) {
+ sysv_calc(elf, &elfhdr,
+ &shdr, 1);
+ }
+ }
+ sysv_header(name, arhdr);
+ scn = NULL;
+ while ((scn = elf_nextscn(elf, scn)) != NULL) {
+ if (gelf_getshdr(scn, &shdr) != NULL)
+ sysv_calc(elf, &elfhdr,
+ &shdr, 0);
+ }
+ }
+ if (style == STYLE_BERKELEY) {
+ if (arhdr != NULL) {
+ berkeley_footer(name, arhdr->ar_name,
+ "ex");
+ } else {
+ berkeley_footer(name, NULL, "ex");
+ }
+ } else {
+ sysv_footer();
+ }
+ }
+ elf_cmd = elf_next(elf);
+ (void) elf_end(elf);
+ }
+ (void) elf_end(elf1);
+ (void) close(fd);
+ return (EX_OK);
+}
+
+void
+print_number(int width, uint32_t num, enum radix_style rad, char c)
+{
+ char buffer[BUF_SIZE];
+
+ (void) snprintf(buffer, BUF_SIZE, (rad == RADIX_DECIMAL ? "%lu" :
+ ((rad == RADIX_OCTAL) ? "0%lo" : "0x%lx")),
+ (unsigned long int)num);
+ (void) printf("%-*s%c", width, buffer, c);
+}
+
+/*
+ * Sysv formatting helper functions.
+ */
+void
+sysv_header(const char *name, Elf_Arhdr *arhdr)
+{
+ text_size_total = 0;
+ if (arhdr != NULL) {
+ (void) printf("%s (ex %s):\n%-*s%-10s %-10s\n",
+ arhdr->ar_name, name, (int)sec_name_len,
+ "section","size","addr");
+ } else {
+ (void) printf("%s :\n%-*s%-10s %-10s\n",
+ name, (int)sec_name_len, "section",
+ "size", "addr");
+ }
+}
+
+void
+sysv_calc(Elf *elf, GElf_Ehdr *elfhdr, GElf_Shdr *shdr, int dry_run)
+{
+ char *section_name;
+
+ section_name = elf_strptr(elf, elfhdr->e_shstrndx,
+ (size_t)shdr->sh_name);
+ if (!dry_run) {
+ if ((shdr->sh_type == SHT_SYMTAB ||
+ shdr->sh_type == SHT_STRTAB || shdr->sh_type == SHT_RELA ||
+ shdr->sh_type == SHT_REL) && shdr->sh_addr == 0)
+ return;
+ (void) printf("%-*s", (int)sec_name_len, section_name);
+ print_number(10, (uint32_t)shdr->sh_size, radix, ' ');
+ print_number(10, (uint32_t)shdr->sh_addr, radix, '\n');
+ text_size_total += shdr->sh_size;
+ } else {
+ if (sec_name_len < strlen(section_name))
+ sec_name_len = strlen(section_name) + 3;
+ }
+}
+
+void
+sysv_footer()
+{
+ (void) printf("%-*s", (int)sec_name_len, "Total");
+ print_number(10, text_size_total, radix, '\n');
+ (void) printf("\n");
+}
+
+/*
+ * berkeley style output formatting helper functions.
+ */
+void
+berkeley_header()
+{
+ text_size = data_size = bss_size = 0;
+}
+
+void
+berkeley_calc(GElf_Shdr *shdr)
+{
+ if (shdr != NULL) {
+ if (!(shdr->sh_flags & SHF_ALLOC))
+ return;
+ if ((shdr->sh_flags & SHF_ALLOC) &&
+ ((shdr->sh_flags & SHF_EXECINSTR) ||
+ !(shdr->sh_flags & SHF_WRITE)))
+ text_size += shdr->sh_size;
+ else if ((shdr->sh_flags & SHF_ALLOC) &&
+ (shdr->sh_flags & SHF_WRITE) &&
+ (shdr->sh_type != SHT_NOBITS))
+ data_size += shdr->sh_size;
+ else
+ bss_size += shdr->sh_size;
+ }
+}
+
+void
+berkeley_totals(void)
+{
+ long unsigned int grand_total;
+
+ if (show_totals) {
+ grand_total = text_size_total + data_size_total +
+ bss_size_total;
+ print_number(10, text_size_total, radix, ' ');
+ print_number(10, data_size_total, radix, ' ');
+ print_number(10, bss_size_total, radix, ' ');
+ if (radix == RADIX_OCTAL)
+ print_number(10, grand_total, RADIX_OCTAL, ' ');
+ else
+ print_number(10, grand_total, RADIX_DECIMAL, ' ');
+ (void) printf("%-10lx (TOTALS)\n", grand_total);
+ }
+}
+
+void
+berkeley_footer(const char *name, const char *ar_name, const char *msg)
+{
+ static int header_printed;
+ const char *col_name;
+
+ if (!header_printed) {
+ (radix == RADIX_OCTAL) ? (col_name = "oct") :
+ (col_name = "dec");
+ (void) printf("%-10s %-10s %-10s %-10s %-10s filename\n",
+ "text","data","bss",col_name,"hex");
+ header_printed = 1;
+ }
+
+ total_size = text_size + data_size + bss_size;
+ if (show_totals) {
+ text_size_total += text_size;
+ bss_size_total += bss_size;
+ data_size_total += data_size;
+ }
+
+ print_number(10, text_size, radix, ' ');
+ print_number(10, data_size, radix, ' ');
+ print_number(10, bss_size, radix, ' ');
+ if (radix == RADIX_OCTAL)
+ print_number(10, total_size, RADIX_OCTAL, ' ');
+ else
+ print_number(10, total_size, RADIX_DECIMAL, ' ');
+ (void) printf("%-10lx\t", (long unsigned int)total_size);
+ if (ar_name != NULL && name != NULL)
+ (void) printf("%s (%s %s)\n", ar_name, msg, name);
+ else if (ar_name != NULL && name == NULL)
+ (void) printf("%s (%s)\n", ar_name, msg);
+ else
+ (void) printf("%s\n", name);
+}
+
+void
+usage()
+{
+ (void) fprintf(stderr, "usage: size [-Adhotx] file ...\n");
+ exit(EX_USAGE);
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jk...@us...> - 2008-04-02 09:44:30
|
Revision: 3
http://elftoolchain.svn.sourceforge.net/elftoolchain/?rev=3&view=rev
Author: jkoshy
Date: 2008-04-02 02:44:26 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Add an implementation of strings(1) contributed by Sam Arun Raj.
Added Paths:
-----------
projects/strings/trunk/Makefile
projects/strings/trunk/strings.1
projects/strings/trunk/strings.c
Added: projects/strings/trunk/Makefile
===================================================================
--- projects/strings/trunk/Makefile (rev 0)
+++ projects/strings/trunk/Makefile 2008-04-02 09:44:26 UTC (rev 3)
@@ -0,0 +1,8 @@
+#
+
+PROG= strings
+WARNS?= 6
+LDADD= -lelf
+
+.include <bsd.prog.mk>
+
Added: projects/strings/trunk/strings.1
===================================================================
--- projects/strings/trunk/strings.1 (rev 0)
+++ projects/strings/trunk/strings.1 2008-04-02 09:44:26 UTC (rev 3)
@@ -0,0 +1,141 @@
+.\" Copyright (c) 2007 S.Sam Arun Raj
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd April 15, 2007
+.Dt STRINGS 1
+.Os
+.Sh NAME
+.Nm strings
+.Nd "print the strings of printable characters in files"
+.Sh SYNOPSIS
+.Nm
+.Op Fl afho
+.Op Fl e Ar encoding
+.Op Fl n Ar number
+.Op Fl t Ar radix
+.Op Ar
+.Sh DESCRIPTION
+Fo each
+.Ar file
+given, the
+.Nm
+utility prints any contiguous seqeunce of printable
+characters of atleast 'n' characters long (the default is 4 characters)
+followed by an unprintable character.
+.Nm
+only scans the initialized and loaded sections of ELF objects; for other
+file types, the entire file is scanned.
+The
+.Nm
+utility is mainly useful for determining the contents of non-text files.
+.Pp
+If no file name is specified in the input, standard input is read from.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl a
+This option instructs
+.Nm
+to scan the entire file. This is useful to override the default behaviour of
+scanning only initialized and loaded section of ELF objects.
+.It Fl e Ar encoding
+Select the character encoding to be used while searching for strings.
+The encoding depends on the single character argument which speicifes
+the encoding;
+.Ar s
+for single 7-bit-byte characters (ASCII, ISO 8859, etc., default).
+.Ar S
+for single 8-bit-byte characters.
+.Ar l
+for 16-bit littleendian.
+.Ar b
+for 16-bit bigendian.
+.Ar L
+for 32-bit littleendian.
+.Ar B
+for 32-bit bigendian.
+.It Fl f
+Print the name of the file before each string.
+.It Fl t Ar radix
+Print the offset from the start of the file before each string. The
+format depends on the single character argument which specifies the
+radix of the offset;
+.Ar d
+for decimal,
+.Ar o
+for octal,
+.Ar x
+for hexadecimal.
+.It Fl n Ar number
+Print the contiguous character sequence of alteast
+.Ar number
+characters long, instead of default 4 characters.
+.It Fl o
+This is same as -t o.
+.It Fl h
+This prints a usage summary and exits.
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh EXAMPLES
+The following are examples of typical usage
+of the
+.Nm
+command:
+.Dl ""
+.Dl "$ strings /bin/ls"
+.Dl "$ strings -a /bin/ln"
+.Dl "$ strings -a -f -t x /bin/cat"
+.Sh SEE ALSO
+.Xr ar 1 ,
+.Xr nm 1 ,
+.Xr objdump 1 ,
+.Xr ranlib ,
+.Xr readelf 1
+.Sh HISTORY
+The first FreeBSD
+.Nm
+utility appeared in
+.Fx v3.
+It was later discontinued in
+.Fx v5 ,
+when i386-only a.out format was dropped in favor of ELF.
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+utility was re-written by
+.An S.Sam Arun Raj Aq sam...@gm...
+This manual page was written by
+.An S.Sam Arun Raj Aq sam...@gm...
+.Sh LIMITATIONS
+Unlike the GNU
+.Nm
+this doesn't support multiple object file formats, only ELF using the
+.Xr elf 3
+and
+.Xr gelf 3
+API's.
Added: projects/strings/trunk/strings.c
===================================================================
--- projects/strings/trunk/strings.c (rev 0)
+++ projects/strings/trunk/strings.c 2008-04-02 09:44:26 UTC (rev 3)
@@ -0,0 +1,411 @@
+/*-
+ * Copyright (c) 2007 S.Sam Arun Raj
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <inttypes.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#include <libelf.h>
+#include <gelf.h>
+
+enum radix_style {
+ RADIX_DECIMAL,
+ RADIX_HEX,
+ RADIX_OCTAL
+};
+
+enum encoding_style {
+ ENCODING_7BIT,
+ ENCODING_8BIT,
+ ENCODING_16BIT_BIG,
+ ENCODING_16BIT_LITTLE,
+ ENCODING_32BIT_BIG,
+ ENCODING_32BIT_LITTLE
+};
+
+#define PRINTABLE(c) \
+ ((c) >= 0 && (c) <= 255 && \
+ ((c) == '\t' || isprint((c)) || \
+ (encoding == ENCODING_8BIT && (c) > 127)))
+
+
+int encoding_size, entire_file, min_len, show_filename, show_loc;
+enum encoding_style encoding;
+enum radix_style radix;
+
+long getcharacter(void);
+int handle_file(const char *);
+int handle_elf(const char *, int);
+int handle_binary(const char *, int);
+int find_strings(const char *, off_t, off_t);
+void usage(void);
+
+/*
+ * strings(1) extracts text(contiguous printable characters)
+ * from elf and binary files.
+ */
+int
+main(int argc, char **argv)
+{
+ int ch, rc;
+
+ rc = EX_OK;
+ min_len = 0;
+ encoding_size = 1;
+ if (elf_version(EV_CURRENT) == EV_NONE)
+ errx(EX_SOFTWARE, "ELF library initialization failed: %s",
+ elf_errmsg(-1));
+
+ while ((ch = getopt(argc, argv, "1234567890ae:fhn:ot:")) != -1)
+ switch((char)ch) {
+ case 'a':
+ entire_file = 1;
+ break;
+ case 'e':
+ if (*optarg == 's') {
+ encoding = ENCODING_7BIT;
+ } else if (*optarg == 'S') {
+ encoding = ENCODING_8BIT;
+ } else if (*optarg == 'b') {
+ encoding = ENCODING_16BIT_BIG;
+ encoding_size = 2;
+ } else if (*optarg == 'B') {
+ encoding = ENCODING_32BIT_BIG;
+ encoding_size = 4;
+ } else if (*optarg == 'l') {
+ encoding = ENCODING_16BIT_LITTLE;
+ encoding_size = 2;
+ } else if (*optarg == 'L') {
+ encoding = ENCODING_32BIT_LITTLE;
+ encoding_size = 4;
+ } else
+ usage();
+ /* NOTREACHED */
+ break;
+ case 'f':
+ show_filename = 1;
+ break;
+ case 'n':
+ min_len = (int)strtoimax(optarg, (char**)NULL, 10);
+ break;
+ case 'o':
+ show_loc = 1;
+ radix = RADIX_OCTAL;
+ break;
+ case 't':
+ show_loc = 1;
+ if (*optarg == 'd')
+ radix = RADIX_DECIMAL;
+ else if (*optarg == 'o')
+ radix = RADIX_OCTAL;
+ else if (*optarg == 'x')
+ radix = RADIX_HEX;
+ else
+ usage();
+ /* NOTREACHED */
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ min_len *= 10;
+ min_len += ch - '0';
+ break;
+ case 'h':
+ case '?':
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (!min_len)
+ min_len = 4;
+ if (!*argv)
+ rc = handle_file("{standard input}");
+ else while (*argv) {
+ rc = handle_file(*argv);
+ argv++;
+ }
+ return(rc);
+}
+
+int
+handle_file(const char *name)
+{
+ int fd, rt;
+
+ if (name == NULL)
+ return(EX_NOINPUT);
+ if (strcmp("{standard input}", name) != 0) {
+ if (freopen(name, "rb", stdin) == NULL) {
+ warnx("'%s': %s", name, strerror(errno));
+ return(EX_NOINPUT);
+ }
+ } else {
+ return find_strings(name, (off_t)0, (off_t)0);
+ }
+
+ fd = fileno(stdin);
+ if (fd < 0)
+ return(EX_NOINPUT);
+ rt = handle_elf(name, fd);
+ return(rt);
+}
+
+/*
+ * Files not understood by handle_elf, will be passed off here and will
+ * treated as a binary file. This would include text file, core dumps ...
+ */
+int
+handle_binary(const char *name, int fd)
+{
+ struct stat buf;
+
+ memset(&buf, 0, sizeof(struct stat));
+ (void) lseek(fd, (off_t)0, SEEK_SET);
+ if (!fstat(fd, &buf))
+ return find_strings(name, (off_t)0, buf.st_size);
+ return(EX_SOFTWARE);
+}
+
+/*
+ * Will analyse a file to see if it ELF, other files including ar(1),
+ * core dumps are passed off and treated as flat binary files. Unlike
+ * GNU size in FreeBSD this routine will not treat ELF object from
+ * different archs as flat binary files(has to overridden using -a).
+ */
+int
+handle_elf(const char *name, int fd)
+{
+ GElf_Ehdr elfhdr;
+ GElf_Shdr shdr;
+ Elf *elf;
+ Elf_Scn *scn;
+ int rc;
+
+ rc = EX_OK;
+ /* If entire file is choosen, treat it as a binary file */
+ if (entire_file)
+ return handle_binary(name, fd);
+
+ (void) lseek(fd, (off_t)0, SEEK_SET);
+ elf = elf_begin(fd, ELF_C_READ, NULL);
+ if (elf_kind(elf) != ELF_K_ELF) {
+ (void) elf_end(elf);
+ return handle_binary(name, fd);
+ }
+
+ if (gelf_getehdr(elf, &elfhdr) == NULL) {
+ (void) elf_end(elf);
+ warnx("%s: ELF file could not be processed", name);
+ return(EX_SOFTWARE);
+ }
+
+ if (elfhdr.e_shnum == 0 && elfhdr.e_type == ET_CORE) {
+ (void) elf_end(elf);
+ return handle_binary(name, fd);
+ } else {
+ scn = NULL;
+ while ((scn = elf_nextscn(elf, scn)) != NULL) {
+ if (gelf_getshdr(scn, &shdr) == NULL)
+ continue;
+ if (shdr.sh_type != SHT_NOBITS &&
+ (shdr.sh_flags & SHF_ALLOC) != 0) {
+ rc = find_strings(name, shdr.sh_offset,
+ shdr.sh_size);
+ }
+ }
+ }
+ (void) elf_end(elf);
+ return(rc);
+}
+
+/*
+ * Retrieves a character from input stream based on the encoding
+ * type requested.
+ */
+long
+getcharacter()
+{
+ long rt;
+ int i;
+ char buf[4], c;
+
+ rt = EOF;
+ for(i = 0; i < encoding_size; i++) {
+ c = getc(stdin);
+ if (feof(stdin))
+ return(EOF);
+ buf[i] = c;
+ }
+
+ switch(encoding) {
+ case ENCODING_7BIT:
+ case ENCODING_8BIT:
+ rt = buf[0];
+ break;
+ case ENCODING_16BIT_BIG:
+ rt = (buf[0] << 8) | buf[1];
+ break;
+ case ENCODING_16BIT_LITTLE:
+ rt = buf[0] | (buf[1] << 8);
+ break;
+ case ENCODING_32BIT_BIG:
+ rt = ((long) buf[0] << 24) | ((long) buf[1] << 16) |
+ ((long) buf[2] << 8) | buf[3];
+ break;
+ case ENCODING_32BIT_LITTLE:
+ rt = buf[0] | ((long) buf[1] << 8) | ((long) buf[2] << 16) |
+ ((long) buf[3] << 24);
+ break;
+ }
+ return(rt);
+}
+
+/*
+ * Input stream stdin is read until the end of file is reached or until
+ * the section size is reached in case of ELF files. Contiguous
+ * characters of >= min_size(default 4) will be displayed.
+ */
+int
+find_strings(const char *name, off_t offset, off_t size)
+{
+ off_t cur_off, start_off;
+ char *obuf;
+ long c;
+ int i;
+
+ if ((obuf = (char*)calloc(1, min_len + 1)) == NULL) {
+ (void) fprintf(stderr, "Unable to allocate memory: %s\n",
+ strerror(errno));
+ return(EX_SOFTWARE);
+ }
+
+ (void) fseeko(stdin, offset, SEEK_SET);
+ cur_off = offset;
+ start_off = 0;
+ while(1) {
+ if ((offset + size) && (cur_off >= offset + size))
+ break;
+ start_off = cur_off;
+ memset(obuf, 0, min_len+1);
+ for(i = 0; i < min_len; i++) {
+ c = getcharacter();
+ if (c == EOF && feof(stdin))
+ goto _exit1;
+ if (PRINTABLE(c)) {
+ obuf[i] = c;
+ obuf[i+1] = 0;
+ cur_off += encoding_size;
+ } else {
+ if (encoding == ENCODING_8BIT &&
+ (uint8_t)c > 127) {
+ obuf[i] = c;
+ obuf[i+1] = 0;
+ cur_off += encoding_size;
+ continue;
+ }
+ cur_off += encoding_size;
+ break;
+ }
+ }
+
+ if (i >= min_len && ((cur_off <= offset + size) ||
+ !(offset + size))) {
+ if (show_filename)
+ printf ("%s: ", name);
+ if (show_loc) {
+ switch(radix) {
+ case RADIX_DECIMAL:
+ (void) printf("%7Ld ",
+ (uint64_t)start_off);
+ break;
+ case RADIX_HEX:
+ (void) printf("%7Lx ",
+ (uint64_t)start_off);
+ break;
+ case RADIX_OCTAL:
+ (void) printf("%7Lo ",
+ (uint64_t)start_off);
+ break;
+ }
+ }
+ printf("%s", obuf);
+
+ while(1) {
+ if ((offset + size) &&
+ (cur_off >= offset + size))
+ break;
+ c = getcharacter();
+ cur_off += encoding_size;
+ if (encoding == ENCODING_8BIT &&
+ (uint8_t)c > 127) {
+ putchar(c);
+ continue;
+ }
+ if (!PRINTABLE(c) || c == EOF)
+ break;
+ putchar(c);
+ }
+ putchar('\n');
+ }
+ }
+_exit1:
+ free(obuf);
+ return(EX_OK);
+}
+
+void
+usage()
+{
+ (void) fprintf(stderr,
+ "strings [-afho] [-e s|S|l|L|b|B] [-n #] [-t o|x|d] file ...\n");
+ exit(EX_USAGE);
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jk...@us...> - 2008-04-01 09:16:28
|
Revision: 2
http://elftoolchain.svn.sourceforge.net/elftoolchain/?rev=2&view=rev
Author: jkoshy
Date: 2008-04-01 02:16:25 -0700 (Tue, 01 Apr 2008)
Log Message:
-----------
Import a snapshot of the libelf test suite from FreeBSD's Perforce
repository.
Added Paths:
-----------
projects/libelf-test-suite/trunk/Makefile
projects/libelf-test-suite/trunk/README
projects/libelf-test-suite/trunk/tet_code
projects/libelf-test-suite/trunk/tet_scen
projects/libelf-test-suite/trunk/tetbuild.cfg
projects/libelf-test-suite/trunk/tetclean.cfg
projects/libelf-test-suite/trunk/tetexec.cfg
projects/libelf-test-suite/trunk/tset/
projects/libelf-test-suite/trunk/tset/Makefile
projects/libelf-test-suite/trunk/tset/Makefile.tset
projects/libelf-test-suite/trunk/tset/bin/
projects/libelf-test-suite/trunk/tset/bin/elf-hash
projects/libelf-test-suite/trunk/tset/bin/elfc
projects/libelf-test-suite/trunk/tset/bin/munge-ts
projects/libelf-test-suite/trunk/tset/common/
projects/libelf-test-suite/trunk/tset/common/Makefile
projects/libelf-test-suite/trunk/tset/common/check_elf.yaml
projects/libelf-test-suite/trunk/tset/common/ehdr.yaml
projects/libelf-test-suite/trunk/tset/common/ehdr_template.c
projects/libelf-test-suite/trunk/tset/common/elf_flag.m4
projects/libelf-test-suite/trunk/tset/common/elfts-compare-files.c
projects/libelf-test-suite/trunk/tset/common/elfts-initversion.c
projects/libelf-test-suite/trunk/tset/common/elfts-openfile.c
projects/libelf-test-suite/trunk/tset/common/elfts.h
projects/libelf-test-suite/trunk/tset/common/elfts.m4
projects/libelf-test-suite/trunk/tset/common/fsize.yaml
projects/libelf-test-suite/trunk/tset/common/gelf_ehdr_template.h
projects/libelf-test-suite/trunk/tset/common/getclass.yaml
projects/libelf-test-suite/trunk/tset/common/getshdr.m4
projects/libelf-test-suite/trunk/tset/common/newehdr.yaml
projects/libelf-test-suite/trunk/tset/common/newehdr_template.c
projects/libelf-test-suite/trunk/tset/common/newscn.yaml
projects/libelf-test-suite/trunk/tset/common/phdr.yaml
projects/libelf-test-suite/trunk/tset/common/phdr_template.c
projects/libelf-test-suite/trunk/tset/common/shdr.yaml
projects/libelf-test-suite/trunk/tset/common/u1.yaml
projects/libelf-test-suite/trunk/tset/common/xlate.yaml
projects/libelf-test-suite/trunk/tset/common/xlate_template.c
projects/libelf-test-suite/trunk/tset/common/xlate_template.m4
projects/libelf-test-suite/trunk/tset/common/xscn-1.yaml
projects/libelf-test-suite/trunk/tset/common/xscn-2.yaml
projects/libelf-test-suite/trunk/tset/common/xscn-3.yaml
projects/libelf-test-suite/trunk/tset/elf32_getehdr/
projects/libelf-test-suite/trunk/tset/elf32_getehdr/Makefile
projects/libelf-test-suite/trunk/tset/elf32_getehdr/ehdr.c
projects/libelf-test-suite/trunk/tset/elf32_getphdr/
projects/libelf-test-suite/trunk/tset/elf32_getphdr/Makefile
projects/libelf-test-suite/trunk/tset/elf32_getphdr/phdr.c
projects/libelf-test-suite/trunk/tset/elf32_getshdr/
projects/libelf-test-suite/trunk/tset/elf32_getshdr/Makefile
projects/libelf-test-suite/trunk/tset/elf32_getshdr/shdr.m4
projects/libelf-test-suite/trunk/tset/elf32_newehdr/
projects/libelf-test-suite/trunk/tset/elf32_newehdr/Makefile
projects/libelf-test-suite/trunk/tset/elf32_newehdr/ehdr.c
projects/libelf-test-suite/trunk/tset/elf32_xlate/
projects/libelf-test-suite/trunk/tset/elf32_xlate/Makefile
projects/libelf-test-suite/trunk/tset/elf32_xlate/xlate.c
projects/libelf-test-suite/trunk/tset/elf32_xlatetof/
projects/libelf-test-suite/trunk/tset/elf32_xlatetof/Makefile
projects/libelf-test-suite/trunk/tset/elf32_xlatetof/xlate.m4
projects/libelf-test-suite/trunk/tset/elf32_xlatetom/
projects/libelf-test-suite/trunk/tset/elf32_xlatetom/Makefile
projects/libelf-test-suite/trunk/tset/elf32_xlatetom/xlate.m4
projects/libelf-test-suite/trunk/tset/elf64_getehdr/
projects/libelf-test-suite/trunk/tset/elf64_getehdr/Makefile
projects/libelf-test-suite/trunk/tset/elf64_getehdr/ehdr.c
projects/libelf-test-suite/trunk/tset/elf64_getphdr/
projects/libelf-test-suite/trunk/tset/elf64_getphdr/Makefile
projects/libelf-test-suite/trunk/tset/elf64_getphdr/phdr.c
projects/libelf-test-suite/trunk/tset/elf64_getshdr/
projects/libelf-test-suite/trunk/tset/elf64_getshdr/Makefile
projects/libelf-test-suite/trunk/tset/elf64_getshdr/shdr.m4
projects/libelf-test-suite/trunk/tset/elf64_newehdr/
projects/libelf-test-suite/trunk/tset/elf64_newehdr/Makefile
projects/libelf-test-suite/trunk/tset/elf64_newehdr/ehdr.c
projects/libelf-test-suite/trunk/tset/elf64_xlate/
projects/libelf-test-suite/trunk/tset/elf64_xlate/Makefile
projects/libelf-test-suite/trunk/tset/elf64_xlate/xlate.c
projects/libelf-test-suite/trunk/tset/elf64_xlatetof/
projects/libelf-test-suite/trunk/tset/elf64_xlatetof/Makefile
projects/libelf-test-suite/trunk/tset/elf64_xlatetof/xlate.m4
projects/libelf-test-suite/trunk/tset/elf64_xlatetom/
projects/libelf-test-suite/trunk/tset/elf64_xlatetom/Makefile
projects/libelf-test-suite/trunk/tset/elf64_xlatetom/xlate.m4
projects/libelf-test-suite/trunk/tset/elf_begin/
projects/libelf-test-suite/trunk/tset/elf_begin/Makefile
projects/libelf-test-suite/trunk/tset/elf_begin/begin.m4
projects/libelf-test-suite/trunk/tset/elf_cntl/
projects/libelf-test-suite/trunk/tset/elf_cntl/Makefile
projects/libelf-test-suite/trunk/tset/elf_cntl/cntl.m4
projects/libelf-test-suite/trunk/tset/elf_end/
projects/libelf-test-suite/trunk/tset/elf_end/Makefile
projects/libelf-test-suite/trunk/tset/elf_end/end.c
projects/libelf-test-suite/trunk/tset/elf_errmsg/
projects/libelf-test-suite/trunk/tset/elf_errmsg/Makefile
projects/libelf-test-suite/trunk/tset/elf_errmsg/errmsg.c
projects/libelf-test-suite/trunk/tset/elf_errno/
projects/libelf-test-suite/trunk/tset/elf_errno/Makefile
projects/libelf-test-suite/trunk/tset/elf_errno/errno.c
projects/libelf-test-suite/trunk/tset/elf_fill/
projects/libelf-test-suite/trunk/tset/elf_fill/Makefile
projects/libelf-test-suite/trunk/tset/elf_fill/fill.m4
projects/libelf-test-suite/trunk/tset/elf_flagdata/
projects/libelf-test-suite/trunk/tset/elf_flagdata/Makefile
projects/libelf-test-suite/trunk/tset/elf_flagdata/data.m4
projects/libelf-test-suite/trunk/tset/elf_flagehdr/
projects/libelf-test-suite/trunk/tset/elf_flagehdr/Makefile
projects/libelf-test-suite/trunk/tset/elf_flagehdr/ehdr.m4
projects/libelf-test-suite/trunk/tset/elf_flagelf/
projects/libelf-test-suite/trunk/tset/elf_flagelf/Makefile
projects/libelf-test-suite/trunk/tset/elf_flagelf/elf.m4
projects/libelf-test-suite/trunk/tset/elf_flagphdr/
projects/libelf-test-suite/trunk/tset/elf_flagphdr/Makefile
projects/libelf-test-suite/trunk/tset/elf_flagphdr/phdr.m4
projects/libelf-test-suite/trunk/tset/elf_flagscn/
projects/libelf-test-suite/trunk/tset/elf_flagscn/Makefile
projects/libelf-test-suite/trunk/tset/elf_flagscn/scn.m4
projects/libelf-test-suite/trunk/tset/elf_flagshdr/
projects/libelf-test-suite/trunk/tset/elf_flagshdr/Makefile
projects/libelf-test-suite/trunk/tset/elf_flagshdr/shdr.m4
projects/libelf-test-suite/trunk/tset/elf_fsize/
projects/libelf-test-suite/trunk/tset/elf_fsize/Makefile
projects/libelf-test-suite/trunk/tset/elf_fsize/fsize.c
projects/libelf-test-suite/trunk/tset/elf_getarhdr/
projects/libelf-test-suite/trunk/tset/elf_getarhdr/Makefile
projects/libelf-test-suite/trunk/tset/elf_getarhdr/getarhdr.m4
projects/libelf-test-suite/trunk/tset/elf_getarsym/
projects/libelf-test-suite/trunk/tset/elf_getarsym/Makefile
projects/libelf-test-suite/trunk/tset/elf_getarsym/getarsym.m4
projects/libelf-test-suite/trunk/tset/elf_getbase/
projects/libelf-test-suite/trunk/tset/elf_getbase/Makefile
projects/libelf-test-suite/trunk/tset/elf_getbase/getbase.c
projects/libelf-test-suite/trunk/tset/elf_getident/
projects/libelf-test-suite/trunk/tset/elf_getident/Makefile
projects/libelf-test-suite/trunk/tset/elf_getident/getident.c
projects/libelf-test-suite/trunk/tset/elf_getscn/
projects/libelf-test-suite/trunk/tset/elf_getscn/Makefile
projects/libelf-test-suite/trunk/tset/elf_getscn/getscn.m4
projects/libelf-test-suite/trunk/tset/elf_getshnum/
projects/libelf-test-suite/trunk/tset/elf_getshnum/Makefile
projects/libelf-test-suite/trunk/tset/elf_getshnum/getshnum.m4
projects/libelf-test-suite/trunk/tset/elf_getshstrndx/
projects/libelf-test-suite/trunk/tset/elf_getshstrndx/Makefile
projects/libelf-test-suite/trunk/tset/elf_getshstrndx/getshstrndx.m4
projects/libelf-test-suite/trunk/tset/elf_hash/
projects/libelf-test-suite/trunk/tset/elf_hash/Makefile
projects/libelf-test-suite/trunk/tset/elf_hash/hash.c
projects/libelf-test-suite/trunk/tset/elf_kind/
projects/libelf-test-suite/trunk/tset/elf_kind/Makefile
projects/libelf-test-suite/trunk/tset/elf_kind/kind.c
projects/libelf-test-suite/trunk/tset/elf_memory/
projects/libelf-test-suite/trunk/tset/elf_memory/Makefile
projects/libelf-test-suite/trunk/tset/elf_memory/memory.c
projects/libelf-test-suite/trunk/tset/elf_ndxscn/
projects/libelf-test-suite/trunk/tset/elf_ndxscn/Makefile
projects/libelf-test-suite/trunk/tset/elf_ndxscn/ndxscn.m4
projects/libelf-test-suite/trunk/tset/elf_newscn/
projects/libelf-test-suite/trunk/tset/elf_newscn/Makefile
projects/libelf-test-suite/trunk/tset/elf_newscn/newscn.m4
projects/libelf-test-suite/trunk/tset/elf_next/
projects/libelf-test-suite/trunk/tset/elf_next/Makefile
projects/libelf-test-suite/trunk/tset/elf_next/next.m4
projects/libelf-test-suite/trunk/tset/elf_nextscn/
projects/libelf-test-suite/trunk/tset/elf_nextscn/Makefile
projects/libelf-test-suite/trunk/tset/elf_nextscn/nextscn.m4
projects/libelf-test-suite/trunk/tset/elf_rawfile/
projects/libelf-test-suite/trunk/tset/elf_rawfile/Makefile
projects/libelf-test-suite/trunk/tset/elf_rawfile/rawfile.c
projects/libelf-test-suite/trunk/tset/elf_strptr/
projects/libelf-test-suite/trunk/tset/elf_strptr/Makefile
projects/libelf-test-suite/trunk/tset/elf_strptr/strptr.m4
projects/libelf-test-suite/trunk/tset/elf_update/
projects/libelf-test-suite/trunk/tset/elf_update/Makefile
projects/libelf-test-suite/trunk/tset/elf_update/update.m4
projects/libelf-test-suite/trunk/tset/elf_version/
projects/libelf-test-suite/trunk/tset/elf_version/Makefile
projects/libelf-test-suite/trunk/tset/elf_version/version.c
projects/libelf-test-suite/trunk/tset/gelf_getclass/
projects/libelf-test-suite/trunk/tset/gelf_getclass/Makefile
projects/libelf-test-suite/trunk/tset/gelf_getclass/getclass.c
projects/libelf-test-suite/trunk/tset/gelf_getehdr/
projects/libelf-test-suite/trunk/tset/gelf_getehdr/Makefile
projects/libelf-test-suite/trunk/tset/gelf_getehdr/ehdr.c
projects/libelf-test-suite/trunk/tset/gelf_newehdr/
projects/libelf-test-suite/trunk/tset/gelf_newehdr/Makefile
projects/libelf-test-suite/trunk/tset/gelf_newehdr/ehdr.m4
projects/libelf-test-suite/trunk/tset/gelf_xlate/
projects/libelf-test-suite/trunk/tset/gelf_xlate/Makefile
projects/libelf-test-suite/trunk/tset/gelf_xlate/xlate.c
Added: projects/libelf-test-suite/trunk/Makefile
===================================================================
--- projects/libelf-test-suite/trunk/Makefile (rev 0)
+++ projects/libelf-test-suite/trunk/Makefile 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,31 @@
+#
+
+TET_ROOT?= /home/tmp/tet
+
+.if !defined(TET_EXECUTE)
+TET_EXECUTE!= make -V .OBJDIR
+.endif
+
+.if make(tccbuild)
+TET_OPTIONS+= -b
+.endif
+
+.if make(tccclean)
+TET_OPTIONS+= -c
+.endif
+
+.if make(execute)
+TET_OPTIONS+= -e
+.endif
+
+.MAIN: all
+
+_cmd: .USE
+ TET_EXECUTE=${TET_EXECUTE} TET_SUITE_ROOT=${.CURDIR} \
+ ${TET_ROOT}/bin/tcc ${TET_OPTIONS} .
+
+tccbuild tccclean execute: _cmd
+
+SUBDIR= tset
+
+.include <bsd.subdir.mk>
Added: projects/libelf-test-suite/trunk/README
===================================================================
--- projects/libelf-test-suite/trunk/README (rev 0)
+++ projects/libelf-test-suite/trunk/README 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,85 @@
+: README
+
+This directory contains a test suite for libelf.
+
+: Pre-requisites
+
+1) TET (Test Execution Toolkit) from The Open Group.
+ http://tetworks.opengroup.org/tet/
+
+2) YAML tools for Python.
+ http://pyyaml.org
+
+On FreeBSD, you may install the following ports:
+ - misc/tet, version 3.7 or later
+ - devel/py-yaml, version 3.04 or later
+
+
+: Notes on TET Configuration
+
+Debugging TET executables is much easier if you've built
+the 'lite' version of TET. The LibElf test suite does not
+use TET's distributed testing features, so the 'lite' version
+of TET is sufficient.
+
+The 'lite' version of TET does not need further configuration.
+
+If you chosen to install the 'inet' (distributed) version of TET,
+you'll need a minimal ${TET_ROOT}/systems file. The following
+content in the file is enough for this test suite.
+
+ 000 localhost
+
+For the 'inet' version of TET, you'll need `tccd` running, and a
+`systems.equiv` file in the directory of the user running `tccd`.
+The following contents will do for this file:
+
+ localhost
+
+We use regular 'make' as our build tool. Since make doesn't use
+the TETware API when printing messages we must tell tcc to execute
+make with output capture mode enabled.
+
+TET_BUILD_TOOL=make
+TET_OUTPUT_CAPTURE=True
+
+We'll assume that each test case is in a directory of its
+own and the Makefile in that directory builds that executable
+We don't need the name of the test case to be passed in to 'make'
+
+TET_PASS_TC_NAME=False
+
+Similarly, for cleaning the test suite, we use 'make'.
+
+TET_CLEAN_TOOL=make
+TET_CLEAN_FILE=clean
+
+Since the test cases themselves are API compliant, we'll
+set TET_OUTPUT_CAPTIRE=False for test case execution.
+
+: Notes on TET execution
+
+Edit the top-level 'Makefile' and set the TET_ROOT variable to
+the path where the TET test suite is installed. Once this is
+done:
+
+ * A `make all` at the top level will build the test suite.
+ * A `make execute` will run `tcc`, leaving a log in a `results/`
+ directory.
+
+Here is how to run `tcc` by hand:
+
+ % TET_ROOT=/where/ever TET_EXECUTE=/usr/obj/`pwd` TET_SUITE_ROOT=`pwd` \
+ $TET_ROOT/bin/tcc [-e | -b | -c] .
+
+The TET_ROOT setting points points `tcc` to its configuration files.
+
+TET_EXECUTE points `tcc` to the location of the binaries created by the
+'build' phase. Since we are using FreeBSD `make`, this path would be
+under ${MAKEOBJDIRPREFIX}.
+
+TET_SUITE_ROOT informs `tcc` that the test suite is NOT located under
+${TET_ROOT}.
+
+If all goes well, `tcc` will create a journal file in the
+'results/NNNN[bec]/' directory under ${PWD}.
Added: projects/libelf-test-suite/trunk/tet_code
===================================================================
--- projects/libelf-test-suite/trunk/tet_code (rev 0)
+++ projects/libelf-test-suite/trunk/tet_code 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,15 @@
+# LibELF test suite.
+
+# TET reserved codes
+0 "PASS"
+1 "FAIL"
+2 "UNRESOLVED"
+3 "NOTINUSE"
+4 "UNSUPPORTED"
+5 "UNTESTED"
+6 "UNINITIATED"
+7 "NORESULT"
+
+# Test suite additional codes
+101 "INSPECT"
+
Added: projects/libelf-test-suite/trunk/tet_scen
===================================================================
--- projects/libelf-test-suite/trunk/tet_scen (rev 0)
+++ projects/libelf-test-suite/trunk/tet_scen 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,214 @@
+# LibElf Test Suite
+
+# Scenario file
+
+all
+ ^elf_begin
+ ^elf_cntl
+ ^elf_end
+ ^elf_errmsg
+ ^elf_errno
+ ^elf_fill
+ ^elf_flagdata
+ ^elf_flagehdr
+ ^elf_flagelf
+ ^elf_flagphdr
+ ^elf_flagscn
+ ^elf_flagshdr
+ ^elf_getarhdr
+ ^elf_getarsym
+ ^elf_getbase
+ ^elf_getident
+ ^elf_getscn
+ ^elf_getshnum
+ ^elf_getshstrndx
+ ^elf_hash
+ ^elf_kind
+ ^elf_memory
+ ^elf_next
+ ^elf_ndxscn
+ ^elf_newscn
+ ^elf_nextscn
+ ^elf_rawfile
+ ^elf_strptr
+ ^elf_update
+ ^elf_version
+ ^elf32_getehdr
+ ^elf32_getphdr
+ ^elf32_getshdr
+ ^elf32_newehdr
+ ^elf32_xlatetof
+ ^elf32_xlatetom
+ ^elf64_getehdr
+ ^elf64_getphdr
+ ^elf64_getshdr
+ ^elf64_newehdr
+ ^elf64_xlatetof
+ ^elf64_xlatetom
+ ^fsize
+ ^gelf_getclass
+ ^gelf_getehdr
+ ^gelf_newehdr
+ ^gelf_xlate
+
+# elf_begin has a IC that needs to be invoked separately
+elf_begin
+ /tset/elf_begin/tc_elf_begin{4}
+ /tset/elf_begin/tc_elf_begin{0-3}
+
+elf_cntl
+ /tset/elf_cntl/tc_elf_cntl
+
+elf_end
+ /tset/elf_end/tc_elf_end
+
+elf_errmsg
+ /tset/elf_errmsg/tc_elf_errmsg
+
+elf_errno
+ /tset/elf_errno/tc_elf_errno
+
+elf_fill
+ /tset/elf_fill/tc_elf_fill
+
+elf_flagdata
+ /tset/elf_flagdata/tc_elf_flagdata
+
+elf_flagehdr
+ /tset/elf_flagehdr/tc_elf_flagehdr
+
+elf_flagelf
+ /tset/elf_flagelf/tc_elf_flagelf
+
+elf_flagphdr
+ /tset/elf_flagphdr/tc_elf_flagphdr
+
+elf_flagscn
+ /tset/elf_flagscn/tc_elf_flagscn
+
+elf_flagshdr
+ /tset/elf_flagshdr/tc_elf_flagshdr
+
+elf_getarhdr
+ /tset/elf_getarhdr/tc_elf_getarhdr
+
+elf_getarsym
+ /tset/elf_getarsym/tc_elf_getarsym
+
+elf_getbase
+ /tset/elf_getbase/tc_elf_getbase
+
+elf_getident
+ /tset/elf_getident/tc_elf_getident{0}
+ /tset/elf_getident/tc_elf_getident{1}
+
+elf_getscn
+ /tset/elf_getscn/tc_elf_getscn
+
+elf_getshnum
+ /tset/elf_getshnum/tc_elf_getshnum
+
+elf_getshstrndx
+ /tset/elf_getshstrndx/tc_elf_getshstrndx
+
+elf_hash
+ /tset/elf_hash/tc_elf_hash
+
+elf_kind
+ /tset/elf_kind/tc_elf_kind
+
+elf_memory
+ /tset/elf_memory/tc_elf_memory{0}
+ /tset/elf_memory/tc_elf_memory{1}
+ /tset/elf_memory/tc_elf_memory{2}
+ /tset/elf_memory/tc_elf_memory{3}
+ /tset/elf_memory/tc_elf_memory{4}
+ /tset/elf_memory/tc_elf_memory{5}
+
+elf_ndxscn
+ /tset/elf_ndxscn/tc_elf_ndxscn
+
+elf_next
+ /tset/elf_next/tc_elf_next
+
+elf_newscn
+ /tset/elf_newscn/tc_elf_newscn
+
+elf_nextscn
+ /tset/elf_nextscn/tc_elf_nextscn
+
+elf_rawfile
+ /tset/elf_rawfile/tc_elf_rawfile{0}
+ /tset/elf_rawfile/tc_elf_rawfile{1}
+ /tset/elf_rawfile/tc_elf_rawfile{2}
+ /tset/elf_rawfile/tc_elf_rawfile{3}
+
+elf_strptr
+ /tset/elf_strptr/tc_elf_strptr
+
+elf_update
+ /tset/elf_update/tc_elf_update
+
+elf_version
+ /tset/elf_version/tc_elf_version{0}
+ /tset/elf_version/tc_elf_version{1}
+ /tset/elf_version/tc_elf_version{2}
+ /tset/elf_version/tc_elf_version{3}
+ /tset/elf_version/tc_elf_version{4}
+
+elf32_getehdr
+ /tset/elf32_getehdr/tc_elf32_getehdr
+
+elf32_getphdr
+ /tset/elf32_getphdr/tc_elf32_getphdr
+
+elf32_getshdr
+ /tset/elf32_getshdr/tc_elf32_getshdr
+
+elf32_newehdr
+ /tset/elf32_newehdr/tc_elf32_newehdr
+
+elf32_xlatetof
+ /tset/elf32_xlatetof/tc_elf32_xlatetof
+
+elf32_xlatetom
+ /tset/elf32_xlatetom/tc_elf32_xlatetom
+
+elf64_getehdr
+ /tset/elf64_getehdr/tc_elf64_getehdr
+
+elf64_getphdr
+ /tset/elf64_getphdr/tc_elf64_getphdr
+
+elf64_getshdr
+ /tset/elf64_getshdr/tc_elf64_getshdr
+
+elf64_newehdr
+ /tset/elf64_newehdr/tc_elf64_newehdr
+
+elf64_xlatetof
+ /tset/elf64_xlatetof/tc_elf64_xlatetof
+
+elf64_xlatetom
+ /tset/elf64_xlatetom/tc_elf64_xlatetom
+
+fsize
+ /tset/elf_fsize/tc_elf_fsize{0}
+ /tset/elf_fsize/tc_elf_fsize{1}
+
+getehdr
+ ^elf32_getehdr
+ ^elf64_getehdr
+ ^gelf_getehdr
+
+gelf_getclass
+ /tset/gelf_getclass/tc_gelf_getclass
+
+gelf_getehdr
+ /tset/gelf_getehdr/tc_gelf_getehdr
+
+gelf_newehdr
+ /tset/gelf_newehdr/tc_gelf_newehdr
+
+gelf_xlate
+ /tset/gelf_xlate/tc_gelf_xlate
Added: projects/libelf-test-suite/trunk/tetbuild.cfg
===================================================================
--- projects/libelf-test-suite/trunk/tetbuild.cfg (rev 0)
+++ projects/libelf-test-suite/trunk/tetbuild.cfg 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,5 @@
+# LibElf Test Suite
+
+TET_BUILD_TOOL=make
+TET_OUTPUT_CAPTURE=True
+TET_PASS_TC_NAME=False
Added: projects/libelf-test-suite/trunk/tetclean.cfg
===================================================================
--- projects/libelf-test-suite/trunk/tetclean.cfg (rev 0)
+++ projects/libelf-test-suite/trunk/tetclean.cfg 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,7 @@
+# LibElf Test Suite.
+
+TET_CLEAN_TOOL=make
+TET_CLEAN_FILE=clean
+
+TET_OUTPUT_CAPTURE=True
+TET_PASS_TC_NAME=False
Added: projects/libelf-test-suite/trunk/tetexec.cfg
===================================================================
--- projects/libelf-test-suite/trunk/tetexec.cfg (rev 0)
+++ projects/libelf-test-suite/trunk/tetexec.cfg 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,3 @@
+# LibElf Test Suite.
+
+TET_OUTPUT_CAPTURE=False
Added: projects/libelf-test-suite/trunk/tset/Makefile
===================================================================
--- projects/libelf-test-suite/trunk/tset/Makefile (rev 0)
+++ projects/libelf-test-suite/trunk/tset/Makefile 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,55 @@
+#
+#
+#
+
+SUBDIR+= common # must be first
+
+SUBDIR+= elf_begin
+SUBDIR+= elf_cntl
+SUBDIR+= elf_end
+SUBDIR+= elf_errmsg
+SUBDIR+= elf_errno
+SUBDIR+= elf_fill
+SUBDIR+= elf_flagdata
+SUBDIR+= elf_flagehdr
+SUBDIR+= elf_flagelf
+SUBDIR+= elf_flagphdr
+SUBDIR+= elf_flagscn
+SUBDIR+= elf_flagshdr
+SUBDIR+= elf_fsize
+SUBDIR+= elf_getarhdr
+SUBDIR+= elf_getarsym
+SUBDIR+= elf_getbase
+SUBDIR+= elf_getident
+SUBDIR+= elf_getscn
+SUBDIR+= elf_getshnum
+SUBDIR+= elf_getshstrndx
+SUBDIR+= elf_hash
+SUBDIR+= elf_kind
+SUBDIR+= elf_memory
+SUBDIR+= elf_ndxscn
+SUBDIR+= elf_next
+SUBDIR+= elf_newscn
+SUBDIR+= elf_nextscn
+SUBDIR+= elf_rawfile
+SUBDIR+= elf_strptr
+SUBDIR+= elf_update
+SUBDIR+= elf_version
+SUBDIR+= elf32_getehdr
+SUBDIR+= elf32_getphdr
+SUBDIR+= elf32_getshdr
+SUBDIR+= elf32_newehdr
+SUBDIR+= elf32_xlatetof
+SUBDIR+= elf32_xlatetom
+SUBDIR+= elf64_getehdr
+SUBDIR+= elf64_getphdr
+SUBDIR+= elf64_getshdr
+SUBDIR+= elf64_newehdr
+SUBDIR+= elf64_xlatetof
+SUBDIR+= elf64_xlatetom
+SUBDIR+= gelf_getclass
+SUBDIR+= gelf_getehdr
+SUBDIR+= gelf_newehdr
+SUBDIR+= gelf_xlate
+
+.include <bsd.subdir.mk>
Added: projects/libelf-test-suite/trunk/tset/Makefile.tset
===================================================================
--- projects/libelf-test-suite/trunk/tset/Makefile.tset (rev 0)
+++ projects/libelf-test-suite/trunk/tset/Makefile.tset 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,69 @@
+#
+# A hack to build test cases using make(1)
+#
+
+.if !defined(TET_ROOT)
+.error TET_ROOT must be defined!
+.endif
+
+PROG?= tc_${.CURDIR:T:R}
+TS_ROOT?= ${.CURDIR:H}
+TS_OBJROOT?= ${.OBJDIR:H}
+
+TET_LIBS:= ${TET_ROOT}/lib/tet3
+TET_OBJS:= ${TET_LIBS}/tcm.o
+
+CFLAGS+= -DLIBELF_TEST_HOOKS=1 -I${TET_ROOT}/inc/tet3 \
+ -I${TS_ROOT}/common
+LDADD+= -lelf ${TET_OBJS} -L${TET_LIBS} -lapi
+M4FLAGS+= -I${TS_ROOT}/common
+
+.if defined(TS_SRCS)
+_C_SRCS= ${TS_SRCS:M*.c}
+_M4_SRCS= ${TS_SRCS:M*.m4}
+CLEANFILES+= ${_M4_SRCS:S/.m4/.c/}
+SRCS= ${.OBJDIR}/tc.c ${_C_SRCS} ${_M4_SRCS} # for bsd.prog.mk
+.endif
+
+_TS_OBJS:= ${_C_SRCS:S/.c/.o/g} ${_M4_SRCS:S/.m4/.o/}
+
+${PROG}: ${TS_DATA}
+
+NO_MAN?=1
+
+# generate 'tc.c' from the test case objects
+${.OBJDIR}/tc.c: ${_TS_OBJS}
+ ${TS_ROOT}/bin/munge-ts -o ${.TARGET} ${.ALLSRC}
+
+# generate ELF binary files from YAML desciptions
+.SUFFIXES: .yaml .msb32 .lsb32 .msb64 .lsb64 .m4
+.for e in msb lsb
+.for c in 32 64
+.yaml.${e}${c}:
+ cat ${.IMPSRC} | sed -e 's/ELFDATANONE/ELFDATA2${e:U}/g' \
+ -e 's/ELFCLASSNONE/ELFCLASS${c:U}/g' | \
+ ${TS_ROOT}/bin/elfc -o ${.TARGET}
+.endfor
+.endfor
+
+_TS_YAML?= ${TS_DATA:M*.msb32} ${TS_DATA:M*.lsb32} ${TS_DATA:M*.msb64} \
+ ${TS_DATA:M*.lsb64}
+
+# Copy
+.for f in ${_TS_YAML}
+.if !exists(${f:R}.yaml)
+${f}: ${TS_OBJROOT}/common/${f}
+ cp ${.ALLSRC} ${.TARGET}
+.endif
+.endfor
+
+# M4->C conversion
+.m4.c:
+ m4 ${M4FLAGS} ${.IMPSRC} > ${.TARGET}
+
+CLEANFILES+= ${TS_DATA} ${.OBJDIR}/tc.c
+
+WARNS?= 2
+
+# Bring in rules to build programs
+.include <bsd.prog.mk>
Added: projects/libelf-test-suite/trunk/tset/bin/elf-hash
===================================================================
--- projects/libelf-test-suite/trunk/tset/bin/elf-hash (rev 0)
+++ projects/libelf-test-suite/trunk/tset/bin/elf-hash 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+import sys, os
+
+def elf_hash(s):
+ """A python implementation of elf_hash(3)."""
+ h = 0L
+ for c in s:
+ h = (h << 4) + ord(c)
+ t = (h & 0xF0000000L)
+ if t != 0:
+ h = h ^ (t >> 24)
+ h = h & ~t
+ return h
+
+
+if __name__ == '__main__':
+ from optparse import OptionParser
+
+ usage = "usage: %prog [options] files...\n" + \
+ " print ELF hash values for strings or file contents"
+
+ p = OptionParser(usage=usage)
+ p.add_option("-s", "--string", dest="hash_strings",
+ action="append", metavar="STRING",
+ help="compute hash for STRING")
+
+ options, args = p.parse_args()
+ if not options.hash_strings and not args:
+ p.print_help()
+ sys.exit(1)
+
+ if options.hash_strings:
+ for s in options.hash_strings:
+ print "\"%s\" 0x%x" % (s, elf_hash(s))
+ for f in args:
+ print "[%s] 0x%x" % (f, elf_hash(open(f,'r').read()))
Property changes on: projects/libelf-test-suite/trunk/tset/bin/elf-hash
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/libelf-test-suite/trunk/tset/bin/elfc
===================================================================
--- projects/libelf-test-suite/trunk/tset/bin/elfc (rev 0)
+++ projects/libelf-test-suite/trunk/tset/bin/elfc 2008-04-01 09:16:25 UTC (rev 2)
@@ -0,0 +1,1570 @@
+#!/usr/bin/env python
+#
+# This script converts a textual (YAML) description of an ELF file to
+# an equivalent 'binary' file.
+#
+# The YAML description may have the following top-level keys:
+#
+# 'elf_fillchar': char
+# Sets the fill character to 'char'.
+# 'ehdr': EHDR-DESCRIPTOR
+# Defines an ELF Ehdr structure.
+# 'phdrtab': list-of(PHDR-DESCRIPTOR)
+# Defines the contents of the ELF Program Header table.
+# Each `Phdr' descriptor represents one ELF Phdr entry.
+# 'sections': list-of(SECTION-DESCRIPTOR)
+# Defines the content of each section in the file. Each
+# `SECTION-DESCRIPTOR' contains information for the
+# section `header' and the actual data for the section.
+#
+# The script will compute reasonable defaults for any fields
+# left unspecified in the YAML description.
+#
+# Descriptors EHDR-DESCRIPTOR and PHDR-DESCRIPTOR may be specified
+# as a YAML key-value set. The key names correspond to the
+# field names of the corresponding ELF structures, e.g., 'e_machine'
+# and 'e_ident' for the Ehdr and 'p_type' and 'p_paddr' for
+# a Phdr entry.
+#
+# Descriptor SECTION-DESCRIPTOR contains the fields in an ELF
+# Shdr structure and an additional member 'sh_data', whose
+# value is the data for the section.
+#
+# Example:
+#
+# <snip>
+# ehdr: !Ehdr
+# e_ident: !Ident
+# ei_class: ELFCLASS32
+# ei_data: ELFDATA2MSB
+# e_machine: EM_PPC
+# phdrtab:
+# - !Phdr
+# ph_type: PHT_NULL
+# ... other program header fields ...
+# - !Phdr
+# ... etc. ...
+# sections:
+# - !Section
+# sh_name: .dynsym
+# ... other section header fields ...
+# sh_data: # ... list of data ...
+# - !Dyn
+# d_tag: 0xdeadcode
+# - !Dyn
+# d_tag: 0xcafebabe
+# - !Section
+# sh_name: .shstrtab
+# sh_type: SHT_STRTAB
+# sh_data:
+# - string1
+# - string2
+# </snip>
+#
+# :: Handling of strings ::
+#
+# Fields like 'sh_name' (in a section header) are defined to contain
+# an integer index into a specified string table (in this case a
+# section with name '.shstrtab'). Other ELF data structures use a
+# similar convention; names in a '.dynamic' section as stored as
+# indices into a '.dynstr' section. In the YAML descriptor, such
+# fields may be specified as indices, which are used as-is, or as text
+# strings which are converted to the appropriate string index.
+# For convenience in creating ELF objects with a large number of
+# sections, a section index may be manually specified using a
+# 'sh_index' pseudo field.
+#
+# $FreeBSD$
+
+version = "%prog 1.0"
+usage = "usage: %prog [options] [input-file]"
+description = """Create an ELF binary from a textual description in """ + \
+ """'input-file' (or stdin)"""
+
+import optparse, re, struct, sys, types, yaml
+
+class ElfError(Exception):
+ """An exception signalled during conversion."""
+
+ def __init__(self, node=None, msg=None):
+ """Initialize an exception object.
+
+ Arguments:
+ node -- a YAML parse tree node.
+ msg -- human readable message associated with this
+ exception.
+ """
+ if node:
+ self.ee_start = node.start_mark.line + 1
+ self.ee_end = node.end_mark.line + 1
+ else:
+ self.ee_start = self.ee_end = -1
+ self.ee_msg = msg
+
+ def __str__(self):
+ """Form a printable representation of an exception."""
+
+ if self.ee_start != -1:
+ if self.ee_start == self.ee_end:
+ return "Error: line %d: %s" % (self.ee_start,
+ self.ee_msg)
+ else:
+ return "Error: lines %d--%d: %s" % \
+ (self.ee_start, self.ee_end,
+ self.ee_msg)
+ else:
+ return "Error: %s" % self.ee_msg
+
+
+#
+# Mappings used by the 'encode()' function
+#
+
+elf_cap_tag = {
+ 'CA_SUNW_NULL': 0, 'CA_SUNW_HW_1': 1, 'CA_SUNW_SF_1': 2
+}
+
+elf_d_flags = {
+ 'DF_ORIGIN': 0x0001, 'DF_SYMBOLIC': 0x0002, 'DF_TEXTREL': 0x0004,
+ 'DF_BIND_NOW': 0x0006, 'DF_STATIC_TLS': 0x0010
+}
+
+elf_d_tag = {
+ # from <sys/elf_common.h>
+ 'DT_NULL': 0, 'DT_NEEDED': 1, 'DT_PLTRELSZ': 2, 'DT_PLTGOT': 3,
+ 'DT_HASH': 4, 'DT_STRTAB': 5, 'DT_SYMTAB': 6, 'DT_RELA': 7,
+ 'DT_RELASZ': 8, 'DT_RELAENT': 9, 'DT_STRSZ': 10, 'DT_SYMENT': 11,
+ 'DT_INIT': 12, 'DT_FINI': 13, 'DT_SONAME': 14, 'DT_RPATH': 15,
+ 'DT_SYMBOLIC': 16, 'DT_REL': 17, 'DT_RELSZ': 18, 'DT_RELENT': 19,
+ 'DT_PLTREL': 20, 'DT_DEBUG': 21, 'DT_TEXTREL': 22, 'DT_JMPREL': 23,
+ 'DT_BIND_NOW': 24, 'DT_INIT_ARRAY': 25,'DT_FINI_ARRAY': 26,
+ 'DT_INIT_ARRAYSZ': 27, 'DT_FINI_ARRAYSZ': 28, 'DT_RUNPATH': 29,
+ 'DT_FLAGS': 30, 'DT_ENCODING': 32, 'DT_PREINIT_ARRAY': 32,
+ 'DT_PREINIT_ARRAYSZ': 33, 'DT_LOOS': 0x6000000d, 'DT_HIOS': 0x6ffff000,
+ 'DT_LOPROC': 0x70000000, 'DT_HIPROC': 0x7fffffff,
+ 'DT_SUNW_AUXILIARY': 0x6000000D, 'DT_SUNW_RTLDINF': 0x6000000E,
+ 'DT_SUNW_FILTER': 0x6000000F, 'DT_SUNW_CAP': 0x60000010,
+ # from "usr.bin/elfdump/elfdump.c"
+ 'DT_GNU_PRELINKED': 0x6ffffdf5, 'DT_GNU_CONFLICTSZ': 0x6ffffdf6,
+ 'DT_GNU_LIBLISTSZ': 0x6ffffdf7, 'DT_SUNW_CHECKSUM': 0x6ffffdf78,
+ 'DT_PLTPADSZ': 0x6ffffdf79, 'DT_MOVEENT': 0x6ffffdfa,
+ 'DT_MOVESZ': 0x6ffffdfb, 'DT_FEATURE': 0x6ffffdfc,
+ 'DT_FEATURE': 0x6ffffdfd, 'DT_POSFLAG_1': 0x6ffffdfe,
+ 'DT_SYMINENT': 0x6ffffdff, 'DT_VALRNGHI': 0x6ffffdff, # dup
+ 'DT_ADDRRNGLO': 0x6ffffe00, 'DT_GNU_CONFLICT': 0x6ffffef8,
+ 'DT_GNU_LIBLIST': 0x6ffffef9, 'DT_SUNW_CONFIG': 0x6ffffefa,
+ 'DT_SUNW_DEPAUDIT': 0x6ffffefb, 'DT_SUNW_AUDIT': 0x6ffffefc,
+ 'DT_SUNW_PLTPAD': 0x6ffffefd, 'DT_SUNW_MOVETAB': 0x6ffffefe,
+ 'DT_SYMINFO': 0x6ffffeff, 'DT_ADDRRNGHI': 0x6ffffeff, # dup
+ 'DT_VERSYM': 0x6ffffff0, 'DT_GNU_VERSYM': 0x6ffffff0, # dup
+ 'DT_RELACOUNT': 0x6ffffff9, 'DT_RELCOUNT': 0x6ffffffa,
+ 'DT_FLAGS_1': 0x6ffffffb, 'DT_VERDEF': 0x6ffffffc,
+ 'DT_VERDEFNUM': 0x6ffffffd, 'DT_VERNEED': 0x6ffffffe,
+ 'DT_VERNEEDNUM': 0x6fffffff,
+ 'DT_IA_64_PLT_RESERVE': 0x70000000, 'DT_SUNW_AUXILIARY': 0x7ffffffd,
+ 'DT_SUNW_USED': 0x7ffffffe, 'DT_SUNW_FILTER': 0x7fffffff
+}
+
+elf_dyn_fields = [ 'd_tag', 'd_val', 'd_ptr' ]
+
+elf_ehdr_flags = { # no known flags
+}
+
+elf_ehdr_type = { # e_type
+ 'ET_NONE': 0, 'ET_REL': 1, 'ET_EXEC': 2, 'ET_DYN': 3, 'ET_CORE': 4
+}
+
+elf_ehdr_machine = { # e_machine
+ 'EM_NONE': 0, 'EM_M32': 1, 'EM_SPARC': 2, 'EM_386': 3, 'EM_68K': 4,
+ 'EM_88K': 5, 'EM_486': 6, 'EM_860': 7, 'EM_MIPS': 8, 'EM_S370': 9,
+ 'EM_MIPS_RS3_LE': 10, 'EM_MIPS_RS4_BE': 10, 'EM_PARISC': 15,
+ 'EM_VPP500': 17, 'EM_SPARC32PLUS': 18, 'EM_960': 19, 'EM_PPC': 20,
+ 'EM_PPC64': 21, 'EM_S390': 22, 'EM_V800': 36, 'EM_FR20': 37,
+ 'EM_RH32': 38, 'EM_RCE': 39, 'EM_ARM': 40, 'EM_ALPHA_STD': 41,
+ 'EM_SH': 42, 'EM_SPARCV9': 43, 'EM_TRICORE': 44, 'EM_ARC': 45,
+ 'EM_H8_300': 46, 'EM_H8_300H': 47, 'EM_H8S': 48, 'EM_H8_500': 49,
+ 'EM_IA_64': 50, 'EM_MIPS_X': 51, 'EM_COLDFIRE': 52,
+ 'EM_68HC12': 53, 'EM_MMA': 54, 'EM_PCP': 55, 'EM_NCPU': 56,
+ 'EM_NDR1': 57, 'EM_STARCORE': 58, 'EM_ME16': 59, 'EM_ST100': 60,
+ 'EM_TINYJ': 61, 'EM_X86_64': 62, 'EM_ALPHA': 0x9026
+}
+
+elf_ei_version = { # e_version
+ 'EV_NONE': 0, 'EV_CURRENT': 1
+}
+
+elf_ei_class = {
+ 'ELFCLASSNONE': 0, 'ELFCLASS32': 1, 'ELFCLASS64': 2
+}
+
+elf_ei_data = {
+ 'ELFDATANONE': 0, 'ELFDATA2LSB': 1, 'ELFDATA2MSB': 2
+}
+
+elf_ei_osabi = {
+ 'ELFOSABI_NONE': 0, 'ELFOSABI_HPUX': 1, 'ELFOSABI_NETBSD': 2,
+ 'ELFOSABI_LINUX': 3, 'ELFOSABI_HURD': 4, 'ELFOSABI_86OPEN': 5,
+ 'ELFOSABI_SOLARIS': 6, 'ELFOSABI_AIX': 7, 'ELFOSABI_IRIX': 8,
+ 'ELFOSABI_FREEBSD': 9, 'ELFOSABI_TRU64': 10, 'ELFOSABI_MODESTO': 11,
+ 'ELFOSABI_OPENBSD': 12, 'ELFOSABI_OPENVMS': 13, 'ELFOSABI_NSK': 14,
+ 'ELFOSABI_ARM': 97, 'ELFOSABI_STANDALONE': 255, 'ELFOSABI_SYSV': 0,
+ 'ELFOSABI_MONTEREY': 7
+}
+
+elf_ph_fields = [ 'p_align', 'p_filesz', 'p_flags', 'p_memsz', 'p_offset',
+ 'p_paddr', 'p_type', 'p_vaddr' ]
+
+elf_ph_flags = {
+ 'PF_X': 0x1, 'PF_W': 0x2, 'PF_R': 0x4
+}
+
+elf_ph_type = {
+ 'PT_NULL': 0, 'PT_LOAD': 1, 'PT_DYNAMIC': 2, 'PT_INTERP': 3,
+ 'PT_NOTE': 4, 'PT_SHLIB': 5, 'PT_PHDR': 6, 'PT_TLS': 7,
+ 'PT_LOOS': 0x60000000, 'PT_HIOS': 0x6FFFFFFF,
+ 'PT_SUNW_UNWIND': 0x6464E550, 'PT_GNU_EHFRAME': 0x6464E550, # dup
+ 'PT_SUNWBSS': 0x6FFFFFFA, 'PT_SUNWSTACK': 0x6FFFFFFB,
+ 'PT_SUNWDTRACE': 0x6FFFFFFC, 'PT_SUNWCAP': 0x6FFFFFFD,
+ 'PT_LOPROC': 0x70000000, 'PT_HIPROC': 0x7FFFFFFF
+}
+
+elf_sh_type = {
+ 'SHT_NULL': 0, 'SHT_PROGBITS': 1, 'SHT_SYMTAB': 2, 'SHT_STRTAB': 3,
+ 'SHT_RELA': 4, 'SHT_HASH': 5, 'SHT_DYNAMIC': 6, 'SHT_NOTE': 7,
+ 'SHT_NOBITS': 8, 'SHT_REL': 9, 'SHT_SHLIB': 10, 'SHT_DYNSYM': 11,
+ 'SHT_INIT_ARRAY': 14, 'SHT_FINI_ARRAY': 15, 'SHT_PREINIT_ARRAY': 16,
+ 'SHT_GROUP': 17, 'SHT_SYMTAB_SHNDX': 18, 'SHT_LOOS': 0x60000000,
+ 'SHT_HIOS': 0x6fffffff, 'SHT_LOPROC': 0x70000000,
+ 'SHT_HIPROC': 0x7fffffff, 'SHT_LOUSER': 0x80000000,
+ 'SHT_HIUSER': 0xffffffff,
+ # OS specific types
+ 'SHT_SUNW_dof': 0x6FFFFFF4, 'SHT_SUNW_cap': 0x6FFFFFF5,
+ 'SHT_SUNW_SIGNATURE': 0x6FFFFFF6,
+ 'SHT_SUNW_ANNOTATE': 0x6FFFFFF7, 'SHT_GNU_LIBLIST': 0x6ffffff7, # dup
+ 'SHT_SUNW_DEBUGSTR': 0x6FFFFFF8, 'SHT_SUNW_DEBUG': 0x6FFFFFF9,
+ 'SHT_SUNW_move': 0x6FFFFFFA, 'SHT_SUNW_COMDAT': 0x6FFFFFFB,
+ 'SHT_SUNW_syminfo': 0x6FFFFFFC,
+ 'SHT_GNU_verdef': 0x6ffffffd, 'SHT_SUNW_verdef': 0x6ffffffd, # dup
+ 'SHT_GNU_verneed': 0x6ffffffe, 'SHT_SUNW_verneed': 0x6ffffffe, # dup
+ 'SHT_GNU_versym': 0x6fffffff, 'SHT_SUNW_versym': 0x6fffffff, # dup
+ # Processor specific types
+ 'SHT_IA_64_EXT': 0x70000000, 'SHT_IA_64_UNWIND': 0x70000001
+}
+
+elf_sh_flags = {
+ 'SHF_WRITE': 0x1, 'SHF_ALLOC': 0x2, 'SHF_EXECINSTR': 0x4,
+ 'SHF_MERGE': 0x10, 'SHF_STRINGS': 0x20, 'SHF_INFO_LINK': 0x40,
+ 'SHF_LINK_ORDER': 0x80, 'SHF_OS_NONCONFORMING': 0x100,
+ 'SHF_GROUP': 0x200, 'SHF_TLS': 0x400, 'SHF_MASKOS': 0x0ff00000,
+ 'SHF_MASKPROC': 0xf0000000
+}
+
+elf_st_bindings = {
+ 'STB_LOCAL': 0, 'STB_GLOBAL': 1, 'STB_WEAK': 2
+}
+
+elf_st_flags = {
+ 'SHF_WRITE': 1, 'SHF_ALLOC': 2, 'SHF_EXECINSTR': 4
+}
+
+elf_st_types = {
+ 'STT_NOTYPE': 0, 'STT_OBJECT': 1, 'STT_FUNC': 2, 'STT_SECTION': 3,
+ 'STT_FILE': 3
+}
+
+elf_syminfo_flags = {
+ 'SYMINFO_FLG_DIRECT': 1,
+ 'SYMINFO_FLG_PASSTHRU': 2, 'SYMINFO_FLG_FILTER': 2, # dup
+ 'SYMINFO_FLG_COPY': 4, 'SYMINFO_FLG_LAZYLOAD': 8,
+ 'SYMINFO_FLG_DIRECTBIND': 0x10, 'SYMINFO_FLG_NOEXTDIRECT': 0x20,
+ 'SYMINFO_FLG_AUXILIARY': 0x40
+}
+
+elf_syminfo_boundto_types = {
+ 'SYMINFO_BT_SELF': 0xFFFF, 'SYMINFO_BT_PARENT': 0xFFFE,
+ 'SYMINFO_BT_NONE': 0xFFFD, 'SYMINFO_BT_EXTERN': 0xFFFC
+}
+
+# Defaults
+
+defaults = {
+ # ElfDyn structures
+ 'd_tag': 'DT_NULL',
+ 'd_un': '0',
+
+ # fields in an ELf Executable Header
+ 'e_ehsize': None,
+ 'e_entry': '0',
+ 'e_flags': [ '0' ],
+ 'e_ident': None,
+ 'e_machine': 'EM_NONE',
+ 'e_phentsize': None,
+ 'e_phnum': None,
+ 'e_phoff': None,
+ 'e_shentsize': None,
+ 'e_shnum': None,
+ 'e_shoff': None,
+ 'e_shstrndx': None,
+ 'e_type': 'ET_NONE',
+ 'e_version': 'EV_CURRENT',
+ # e_ident bytes
+ 'ei_class': 'ELFCLASS32',
+ 'ei_data': 'ELFDATA2LSB',
+ 'ei_version': 'EV_CURRENT',
+ 'ei_osabi': 'ELFOSABI_NONE',
+ 'ei_abiversion': '0',
+ # File-wide defaults
+ 'elf_fillchar': '0',
+ # Elf Notes
+ 'n_namesz': None,
+ 'n_descsz': None,
+ 'n_type': '0',
+ 'n_data': [ "", "" ],
+ # Phdr
+ 'p_align': '1',
+ 'p_filesz': '0',
+ 'p_memsz': '0',
+ 'p_flags': [ '0' ],
+ 'p_offset': '0',
+ 'p_paddr': '0',
+ 'p_type': 'PT_NULL',
+ 'p_vaddr': '0',
+ # Shdr
+ 'sh_addr': '0',
+ 'sh_addralign': None,
+ 'sh_data': [],
+ 'sh_entsize': '0',
+ 'sh_flags': [ '0' ],
+ 'sh_info': '0',
+ 'sh_index': None,
+ 'sh_link': '0',
+ 'sh_name': '0',
+ 'sh_offset': None,
+ 'sh_size': None,
+ 'sh_type': 'SHT_NULL'
+}
+
+#
+# Module wide constants.
+#
+
+ELFCLASS32 = elf_ei_class['ELFCLASS32']
+ELFDATA2LSB = elf_ei_data['ELFDATA2LSB']
+SHT_NOBITS = elf_sh_type['SHT_NOBITS']
+SHT_NULL = elf_sh_type['SHT_NULL']
+SHT_STRTAB = elf_sh_type['SHT_STRTAB']
+SHN_LORESERVE= 0xFF00
+SHN_XINDEX = 0xFFFF
+#
+# Helper functions.
+#
+
+def get(d, key, default):
+ """Retrieve the value of 'key' from YAML dictionary 'd'.
+
+ The return value is guaranteed to be not 'None'.
+ """
+ v = d.get(key, default)
+ if v is None:
+ v = default
+ return v
+
+def encode(d, key, default, mapping):
+ """Return the numeric value of d[key] in map 'mapping'."""
+
+ v = get(d, key, default)
+ try:
+ return mapping[v]
+ except KeyError:
+ return int(v)
+
+def encode_flags(flags, m):
+ """Convert 'flags' to a single numeric value using mapping 'm'."""
+ try:
+ v = long(flags)
+ return v
+ except:
+ pass
+ v = 0L
+ for f in flags:
+ try:
+ t = long(m[f])
+ except KeyError:
+ t = long(f)
+ v |= t
+ return v
+
+def check_dict(d, l, node=None):
+ """Check a dictionary for unknown keys."""
+ unknown = []
+ for k in d.keys():
+ if k not in l:
+ unknown.append(k)
+ if len(unknown) > 0:
+ raise ElfError(node, "{%s} Unknown key(s) %s" % \
+ (node.tag, unknown))
+
+#
+# Helper classes.
+#
+
+class ElfStrTab:
+ """A ELF string table.
+
+ This class manages strings in an ELF string table section.
+ """
+
+ def __init__(self, strs=None):
+ """Initialize a string table from a list of strings."""
+ self.offset = 1 # reserve space for initial null byte
+ self.htab = {}
+ if type(strs) == types.StringType: # one string
+ self.add(strs)
+ elif type(strs) == types.ListType: # list of strings
+ for s in strs:
+ self.add(s)
+
+ def add(self, str):
+ """Add a string to the string table.
+
+ Returns the offset of the string in the ELF section."""
+ try:
+ return self.lookup(str)
+ except KeyError:
+ self.htab[str] = offset = self.offset
+ self.offset += len(str) + 1 # Keep space for a NUL.
+ return offset
+
+ def bits(self):
+ """Return the contents of an ELF string table."""
+
+ l = self.htab.items()
+ l.sort(lambda x, y: cmp(x[1],y[1])) # Order by string offset.
+ ls = [""] # initial NUL
+ for (ss,oo) in l:
+ ls.append(ss)
+ return "\000".join(ls) + "\000" # Add trailing NULs
+
+ def lookup(self, str):
+ """Return the ELF string table offset for string 'str'."""
+
+ return self.htab[str]
+
+
+class ElfType:
+ """A base type for ELF type descriptors.
+
+ Derived classes are expected to provide the following attributes:
+
+ 'fields' -- a list of 4-typles (name, fn, lsz, msz).
+
+ 'name' is the name of a field in the ELF structure.
+
+ 'fn' is a convertor function, one of the functions
+ 'do_(long,encode,flags)' below.
+
+ 'msz' and 'lsz' provide the appropriate sizes when
+ generating a binary representation of the type.
+ """
+
+ fields = None
+ def __init__(self, d, node):
+ """Initialize an ELF datatype from a YAML description.
+
+ Arguments:
+ d -- a dictionary containing name/value pairs specified
+ in the text description.
+ node -- YAML parser node for this element.
+ """
+
+ keys = map(lambda t: t[0], self.fields)
+ check_dict(d, keys, node)
+ for f in self.fields:
+ name = f[0]
+ fn = f[1]
+ try:
+ v = fn(d, name)
+ setattr(self,f[0],v)
+ except:
+ raise ElfError(node,
+ 'key: "%s" value: "%s" unrecognized.' % \
+ (name, d[name]))
+ self._n = node # Save YAML node and associated value
+ self._d = d # for error reporting.
+
+ def __getitem__(self, attrib):
+ """Allow an ELF type to be treated like a dictionary."""
+
+ return getattr(self, attrib)
+
+ def bits(self, formatchar, elfclass):
+ """Convert an ELF type to its file representation."""
+
+ format, args = self.getfields(elfclass)
+ return struct.pack(formatchar + format, *args)
+
+ def formatstring(self, elfclass):
+ """Return the format string for this type."""
+
+ if elfclass == ELFCLASS32:
+ n = 2
+ else:
+ n = 3
+ return "".join(map (lambda t: t[n], self.fields))
+
+ def content(self, elfclass):
+ """Return a tuple containing the values for an ELF type."""
+
+ a = []
+ if elfclass == ELFCLASS32:
+ n = 2
+ else:
+ n = 3
+ for t in self.fields:
+ if t[n] != "":
+ a.append(getattr(self, t[0]))
+ return tuple(a)
+
+ def getfields(self, elfclass):
+ """Describe the binary layout of the type.
+
+ Return a tuple (formatstring, *args) describing the
+ desired binary layout in the manner of the 'struct'
+ python library module.
+ """
+
+ return (self.formatstring(elfclass),
+ self.content(elfclass))
+
+ def layout(self, offset, elf):
+ """Perform any layout-time translation for an ELF type."""
+
+ return offset
+
+ def size(self, elfclass):
+ """Return the size of the type in bytes.
+
+ The size returned is independent of the alignment needs of
+ the type.
+ """
+
+ format = self.formatstring(elfclass)
+ sz = 0
+ for f in format:
+ if f == "B":
+ sz += 1
+ elif f == "H":
+ sz += 2
+ elif f == "I":
+ sz += 4
+ elif f == "Q":
+ sz += 8
+ elif f == "":
+ pass
+ else:
+ raise TypeError, "Invalid format char '%s'." % f
+ return sz
+
+
+#
+# Translation helper functions.
+#
+
+def do_string(d, n):
+ """Convert a YAML value to a Python string."""
+
+ v = get(d, n, defaults[n])
+ if v:
+ return str(v)
+ return v
+
+def do_long(d, n):
+ """Convert a YAML value to a Python 'long'."""
+
+ v = get(d, n, defaults[n])
+ if v:
+ return long(v)
+ return v
+
+def do_copy(d, n):
+ """Copy a YAML value without conversion."""
+
+ v = get(d, n, defaults[n])
+ return v
+
+def do_encode(xlate):
+ """Translate a YAML value according to mapping 'xlate'."""
+
+ return lambda d, n, xl=xlate: encode(d, n, defaults[n], xl)
+
+def do_flags(xlate):
+ """Translate a list of flags according to mapping 'xlate'."""
+
+ return lambda d, n, xl=xlate: encode_flags(get(d, n, defaults[n]), xl)
+
+#
+# Definitions of ELF types.
+#
+
+class ElfCap(ElfType):
+ """A representation of an ELF Cap structure.
+
+ YAML tag: !Cap
+ """
+
+ fields = [
+ ('c_tag', do_encode(elf_cap_tag), "I", "Q"),
+ ('c_un', do_long, "I", "Q")
+ ]
+ def __init__(self, cap, node):
+ ElfType.__init__(self, cap, node)
+
+
+class ElfDyn(ElfType):
+ """A representation of an ELF Dyn structure.
+
+ YAML tag: !Dyn
+ """
+
+ fields = [
+ ('d_tag', do_encode(elf_d_tag), "I", "Q"),
+ ('d_un', do_long, "I", "Q")
+ ]
+
+ def __init__(self, d, node):
+ ElfType.__init__(self, d, node)
+
+
+class ElfEhdrIdent(ElfType):
+ """A representation for the 'ident' field of an ELF Ehdr.
+
+ YAML tag: !Ident
+ """
+
+ fields = [
+ ('ei_class', do_encode(elf_ei_class), "B", "B"),
+ ('ei_data', do_encode(elf_ei_data), "B", "B"),
+ ('ei_version', do_encode(elf_ei_version), "B", "B"),
+ ('ei_osabi', do_encode(elf_ei_osabi), "B", "B"),
+ ('ei_abiversion', do_long, "B", "B")
+ ]
+
+ def __init__(self, ei, node):
+ ElfType.__init__(self, ei, node)
+
+ def bits(self, format, elfclass):
+ f, args = self.getfields(elfclass)
+ s = "\x7FELF"
+ s += struct.pack(f + 'xxxxxxx', *args)
+ return s
+
+
+class ElfEhdr(ElfType):
+ """A representation of an ELF Executable Header.
+
+ YAML tag: !Ehdr
+ """
+
+ fields = [
+ ('e_ident', do_copy, "", ""),
+ ('e_type', do_encode(elf_ehdr_type), "H", "H"),
+ ('e_machine', do_encode(elf_ehdr_machine), "H", "H"),
+ ('e_version', do_encode(elf_ei_version), "I", "I"),
+ ('e_entry', do_long, "I", "Q"),
+ ('e_phoff', do_long, "I", "Q"),
+ ('e_shoff', do_long, "I", "Q"),
+ ('e_flags', do_flags(elf_ehdr_flags), "I", "I"),
+ ('e_ehsize', do_long, "H", "H"),
+ ('e_phentsize', do_long, "H", "H"),
+ ('e_phnum', do_long, "H", "H"),
+ ('e_shentsize', do_long, "H", "H"),
+ ('e_shnum', do_long, "H", "H"),
+ ('e_shstrndx', do_copy, "H", "H")
+ ]
+
+ def __init__(self, eh, node):
+ """Initialize an Ehdr structure.
+
+ If an 'ident' structure was not specified as part of
+ the YAML description, initialize it explicitly.
+ """
+
+ ElfType.__init__(self, eh, node)
+ if self.e_ident is None:
+ self.e_ident = ElfEhdrIdent({}, node)
+
+ def layout(self, offset, elf):
+ """Layout an ELF Ehdr.
+
+ This method will fill in defaults and/or compute
+ values for fields that were not specified in the YAML
+ description.
+ """
+
+ elfclass = elf.elfclass()
+ if elfclass == ELFCLASS32:
+ e_ehsize = 52
+ e_phentsize = 32
+ e_shentsize = 40
+ alignment = 4
+ else: # 64 bit sizes
+ e_ehsize = 64
+ e_phentsize = 56
+ e_shentsize = 64
+ alignment = 8
+
+ if self.e_ehsize is None:
+ self.e_ehsize = e_ehsize
+ if self.e_phentsize is None:
+ self.e_phentsize = e_phentsize
+ if self.e_shentsize is None:
+ self.e_shentsize = e_shentsize
+
+ # compute e_phnum if needed
+ if self.e_phnum is None:
+ self.e_phnum = len(elf.elf_phdrtab)
+
+ # The program header defaults to just after the ELF header.
+ if self.e_phoff is None:
+ if self.e_phnum > 0:
+ self.e_phoff = \
+ (self.e_ehsize + (alignment - 1)) & \
+ ~(alignment - 1)
+ else:
+ self.e_phoff = 0
+
+ # compute e_shnum
+ self.nsections = elf.elf_sections.get_shnum()
+ if self.nsections > 0:
+ if self.e_shstrndx is None:
+ self.e_shstrndx = '.shstrtab'
+ if type(self.e_shstrndx) == types.StringType:
+ self.e_shstrndx = \
+ elf.elf_sections.get_index(self.e_shstrndx)
+ elif type(self.e_shstrndx) == types.IntType or \
+ type(self.e_shstrndx) == types.LongType:
+ pass
+ else:
+ raise ElfError(self._n, "Unparseable e_shstrndx field.")
+ if self.e_shstrndx is None:
+ raise ElfError(self._n,
+ 'Cannot determine section ' + \
+ 'name string table index.')
+ else:
+ if self.e_shstrndx is None:
+ self.e_shstrndx = 0
+
+ if self.e_shnum is None:
+ self.e_shnum = self.nsections
+
+ # section data comes after the program header by default. The
+ # section header table is placed after all section data.
+
+ if self.e_phnum > 0:
+ offset = self.e_phoff + self.e_phnum * self.e_phentsize
+ else:
+ offset = self.e_ehsize
+ offset = elf.elf_sections.layout(offset, elf)
+ if self.e_shoff is None:
+ if self.nsections > 0:
+ self.e_shoff = (offset + (alignment-1)) & \
+ ~(alignment-1)
+ else:
+ self.e_shoff = 0
+
+ if self.nsections >= SHN_LORESERVE:
+ elf.elf_sections.set_extended_shnum(self.nsections)
+ self.e_shnum = 0
+ if self.e_shstrndx >= SHN_XINDEX:
+ elf.elf_sections.set_extended_shstrndx(self.e_shstrndx)
+ self.e_shstrndx = SHN_XINDEX
+
+ def bits(self, formatchar, elfclass):
+ """Return the file representation of an Elf Ehdr."""
+
+ s = self.e_ident.bits(formatchar, elfclass)
+ s += ElfType.bits(self, formatchar, elfclass)
+
+ return s
+
+
+class ElfLong:
+ """Wrapper around a python Int/Long."""
+
+ def __init__(self, v):
+ self._v = long(v)
+
+ def bits(self, formatchar, elfclass):
+ """Return the file representation for this object.
+
+ Depending on the number of bits needed to represent
+ the number, the returned bits would be either 4 or
+ 8 bytes wide.
+ """
+
+ if self._v > 0xFFFFFFFFL:
+ f = formatchar + "Q"
+ else:
+ f = formatchar + "I"
+ return struct.pack(f, self._v)
+
+
+class ElfMove(ElfType):
+ """A representation of an Elf Move type.
+
+ YAML tag: !Move
+ """
+
+ fields = [
+ ('m_value', do_long, "I", "I"),
+ ('m_info', do_long, "I", "Q"),
+ ('m_poffset', do_long, "I", "Q"),
+ ('m_repeat', do_long, "H", "H"),
+ ('m_stride', do_long, "H", "H")
+ ]
+
+ def __init__(self, move, node):
+ ElfType.__init__(self, move, node)
+
+
+class ElfNote(ElfType):
+ """A representation of an Elf Note type.
+
+ YAML tag: !Note
+
+ The data in the note is held in YAML node named 'n_data' which is
+ a pair of strings, one for the note's name field and one for the
+ description.
+
+ If the fields 'n_namesz' and 'n_descz' aren't specified, they
+ are computed from the contents of 'n_data'.
+ """
+
+ fields = [
+ ('n_namesz', do_long, "I", "I"),
+ ('n_descsz', do_long, "I", "I"),
+ ('n_type', do_long, "I", "I"),
+ ('n_data', do_copy, "", "")
+ ]
+
+ def __init__(self, note, node):
+ ElfType.__init__(self, note, node)
+ self._note = note
+
+ def layout(self, offset, elfclass):
+ if len(self.n_data) != 2:
+ raise ElfError(node, "Note data not a pair of strings.")
+
+ for nd in self.n_data:
+ if isinstance(nd, ElfType):
+ nd.layout(offset, elfclass)
+
+ if self.n_namesz is None:
+ self.n_namesz = len(self.n_data[0])
+ if self.n_descsz is None:
+ self.n_descsz = len(self.n_data[1])
+
+ def bits(self, format, elfclass):
+ b = ElfType.bits(self, format, elfclass)
+ nbits = str(self.n_data[0])
+ dbits = str(self.n_data[1])
+ return b + nbits + dbits
+
+
+class ElfPhdr(ElfType):
+ """A representation of an ELF Program Header Table entry.
+
+ YAML tag: !Phdr
+ """
+
+ fields = [ # NOTE: class-dependent field ordering
+ ('p_align', do_long),
+ ('p_filesz', do_long),
+ ('p_flags' , do_flags(elf_ph_flags), ),
+ ('p_memsz' , do_long),
+ ('p_offset', do_long),
+ ('p_paddr' , do_long),
+ ('p_type' , do_encode(elf_ph_type)),
+ ('p_vaddr' , do_long)
+ ]
+
+ def __init__(self, ph, node):
+ ElfType.__init__(self, ph, node)
+
+ def to_string(self):
+ """Helper during debugging."""
+
+ s = "Phdr(type:%(p_type)d,flags:%(p_flags)d," \
+ "offset:%(p_offset)ld,vaddr:%(p_vaddr)ld," \
+ "paddr:%(p_paddr)ld,filesz:%(p_filesz)ld," \
+ "memsz:%(p_memsz)ld)" % self
+ return s
+
+ def bits(self, formatchar, elfclass):
+ """Return the file representation of a Phdr."""
+
+ f = formatchar
+ # Phdr structures are laid out in a class-dependent way
+ if elfclass == ELFCLASS32:
+ f += "IIIIIIII"
+ s = struct.pack(f,
+ self.p_type,
+ self.p_offset,
+ self.p_vaddr,
+ self.p_paddr,
+ self.p_filesz,
+ self.p_memsz,
+ self.p_flags,
+ self.p_align)
+ else:
+ f += "IIQQQQQQ"
+ s = struct.pack(f,
+ self.p_type,
+ self.p_flags,
+ self.p_offset,
+ self.p_vaddr,
+ self.p_paddr,
+ self.p_filesz,
+ self.p_memsz,
+ self.p_align)
+ return s
+
+class ElfRel(ElfType):
+ """A representation of an ELF Rel type.
+
+ YAML tag: !Rel
+ """
+
+ fields = [
+ ('r_offset', do_long, "I", "Q"),
+ ('r_info', do_long, "I", "Q")
+ ]
+
+ def __init__(self, rel, node):
+ ElfType.__init__(self, rel, node)
+
+
+class ElfRela(ElfType):
+ """A representation of an ELF Rela type.
+
+ YAML tag: !Rela
+ """
+
+ fields = [
+ ('r_offset', do_long, "I", "Q"),
+ ('r_info', do_long, "I", "Q"),
+ ('r_addend', do_long, "I", "Q")
+ ]
+
+ def __init__(self, rela, node):
+ ElfType.__init__(self, rela, node)
+
+
+class ElfSection(ElfType):
+ """A representation of an ELF Section.
+
+ YAML tag: !Section
+
+ A section description consists of the fields that make up an ELF
+ section header entry and an additional field 'sh_data' that
+ contains the data associated with this section.
+
+ 'sh_data' may be a YAML string, or a YAML list of items that
+ comprise the content of the section.
+ """
+
+ fields = [
+ ('sh_name', do_string, "I", "I"),
+ ('sh_type', do_encode(elf_sh_type), "I", "I"),
+ ('sh_flags', do_flags(elf_sh_flags), "I", "Q"),
+ ('sh_addr', do_long, "I", "Q"),
+ ('sh_offset', do_long, "I", "Q"),
+ ('sh_size', do_long, "I", "Q"),
+ ('sh_link', do_long, "I", "I"),
+ ('sh_info', do_long, "I", "I"),
+ ('sh_addralign', do_copy, "I", "Q"),
+ ('sh_entsize', do_long, "I", "Q"),
+ ('sh_data', do_copy, "", ""),
+ ('sh_index', do_long, "", "")
+ ]
+
+ def __init__(self, shdr, node):
+ """Initialize a section descriptor."""
+
+ ElfType.__init__(self, shdr, node)
+ if type(self.sh_data) != types.ListType:
+ self.sh_data = list(self.sh_data)
+ if self.sh_addralign is None:
+ if self.sh_type == SHT_NULL or self.sh_type == SHT_NOBITS:
+ self.sh_addralign = 0
+ else:
+ self.sh_addralign = 1
+ else:
+ if (self.sh_addralign == 0 or \
+ (self.sh_addralign & (self.sh_addralign - 1)) != 0):
+ raise ElfError(node,
+ "'sh_addralign' not a power of two.")
+ self._data = None # 'cache' of translated data
+ self._strtab = None
+
+ def to_string(self):
+ """Helper function during debugging."""
+
+ return "Section(name:%(sh_name)s,type:%(sh_type)d," \
+ "flags:%(sh_flags)x,addr:%(sh_addr)d,"\
+ "offset:%(sh_offset)d,size:%(sh_size)d," \
+ "link:%(sh_link)d,info:%(sh_info)d," \
+ "addralign:%(sh_addralign)d,entsize:%(sh_entsize)d)" % \
+ self
+
+ def make_strtab(self):
+ """Create a string table from section contents."""
+
+ self._strtab = ElfStrTab(self.sh_data)
+
+ def string_to_index(self, name):
+ """Convert 'name' to an offset inside a string table.
+
+ Only valid for sections of type SHT_STRTAB."""
+
+ if self._strtab:
+ return self._strtab.lookup(name)
+ raise ElfError(None, 'Cannot translate "%s" to an index.' % name)
+
+ def bits(self, formatchar, elfclass):
+ raise AssertionError, "Section objects should use " \
+ "databits() or headerbits()"
+
+ def layout(self, offset, elf):
+ """Prepare an ELF section for output."""
+
+ if type(self.sh_name) == types.StringType:
+ # first try convert it to a long
+ try:
+ self.sh_name = long(self.sh_name)
+ except ValueError: # lookup in string table
+ try:
+ self.sh_name = \
+ elf.section_name_index(self.sh_name)
+ except KeyError:
+ raise ElfError(self._n,
+ "Section name '%s' not in string table." % \
+ self.sh_name)
+ # give a chance for the contents of a section to xlate strings
+ for d in self.sh_data:
+ if isinstance(d, ElfType):
+ d.layout(offset, elf)
+ # compute the space used by the section data
+ self._data = self.databits(elf.formatchar(), elf.elfclass())
+
+ align = self.sh_addralign
+ if align == 0:
+ align = 1
+ if self.sh_type == SHT_NULL or self.sh_type == SHT_NOBITS:
+ isnulltype = 1
+ else:
+ isnulltype = 0
+
+ offset = (offset + (align - 1)) & ~(align - 1)
+ if self.sh_size is None:
+ if isnulltype:
+ self.sh_size = 0
+ else:
+ self.sh_size = len(self._data)
+ if self.sh_offset is None:
+ if isnulltype:
+ self.sh_offset = 0
+ else:
+ self.sh_offset = offset
+ if isnulltype: # ignore bits for null types
+ return offset
+ return offset + len(self._data)
+
+ def databits(self, formatchar, elfclass):
+ """Return the contents of a section."""
+
+ if self._data:
+ return self._data
+ # special-case string table handling
+ if self.sh_type == SHT_STRTAB:
+ return self._strtab.bits()
+ # 'normal' section
+ s = ""
+ for d in self.sh_data:
+ if isinstance(d, ElfType):
+ s += d.bits(formatchar, elfclass)
+ elif isinstance(d, types.LongType):
+ s += struct.pack(formatchar + "Q", d)
+ elif isinstance(d, types.IntType):
+ s += struct.pack(formatchar + "I", d)
+ else:
+ s += str(d)
+ return s
+
+ def headerbits(self, formatchar, elfclass):
+ """Return the file representation of the section header."""
+
+ return ElfType.bits(self, formatchar, elfclass)
+
+
+class ElfSym(ElfType):
+ """A representation for an ELF Symbol type.
+
+ YAML tag: !Sym
+ """
+
+ fields = [ # NOTE: class-dependent layout.
+ ('st_info', do_long, "B", "B"),
+ ('st_name', do_string, "I", "I"),
+ ('st_other', do_long, "B", "B"),
+ ('st_shndx', do_string, "H", "H"),
+ ('st_size', do_long, "I", "Q"),
+ ('st_value', do_long, "I", "Q")
+ ]
+
+ def __init__(self, sym, node):
+ ElfType.__init__(self, sym, node)
+
+ def bits(self, format, elfclass):
+ """Return the file representation for an ELF Sym."""
+
+ if elfclass == ELFCLASS32:
+ s = struct.pack(format + "IIIBBH",
+ self.st_name,
+ self.st_value,
+ self.st_size,
+ self.st_info,
+ self.st_other,
+ self.st_shndx)
+ else:
+ s = struct.pack(format + "IBBHQQ",
+ self.st_name,
+ self.st_info,
+ self.st_other,
+ self.st_shndx,
+ self.st_value,
+ self.st_size)
+ return s
+
+ def layout(self, offset, elf):
+ """Perform layout-time conversions for an ELF Sym.
+
+ String valued fields are converted to offsets into
+ string tables.
+ """
+
+ if type(self.st_shndx) == types.StringType:
+ self.st_shndx = \
+ elf.elf_sections.get_index(self.st_shndx)
+ if self.st_shndx is None:
+ raise ElfError(self._n, "Untranslateable 'st_shndx' " + \
+ "value \"%s\"." % self.st_shndx)
+
+ if type(self.st_name) == types.StringType:
+ try:
+ strtab = \
+ elf.elf_sections[self.st_shndx]._strtab
+ except IndexError:
+ raise ElfError(self._n, "'st_shndx' out of range")
+ if strtab is None:
+ raise ElfError(self._n, "'st_shndx' not of type STRTAB.")
+
+ try:
+ self.st_name = strtab.lookup(self.st_name)
+ except KeyError:
+ raise ElfError(self._n,
+ 'unknown string "%s"' % self.st_name)
+ return offset
+
+
+class ElfSyminfo(ElfType):
+ """A representation of an ELF Syminfo type.
+
+ YAML tag: !Syminfo
+ """
+
+ fields = [
+ ('si_boundto', do_encode(elf_syminfo_boundto_types), "H", "H"),
+ ('si_flags', do_flags(elf_syminfo_flags), "H", "H")
+ ]
+
+ def __init__(self, syminfo, node):
+ ElfType.__init__(self, syminfo, node)
+
+
+class ElfVerdaux(ElfType):
+ """A representation of an ELF Verdaux type."""
+
+ fields = [
+ ('vda_name', do_long, "I", "I"),
+ ('vda_next', do_long, "I", "I")
+ ]
+
+ def __init__(self, verdaux, node):
+ ElfType.__init__(self, verdaux, node)
+
+
+class ElfVerdef(ElfType):
+ """A representation of an ELF Verdef type."""
+
+ fields = [
+ ('vd_version', do_long, "H", "H"),
+ ('vd_flags', do_long, "H", "H"),
+ ('vd_ndx', do_long, "H", "H"),
+ ('vd_cnt', do_long, "H", "H"),
+ ('vd_hash', do_long, "I", "I"),
+ ('vd_aux', do_long, "I", "I"),
+ ('vd_next', do_long, "I", "I")
+ ]
+
+ def __init__(self, verdef, node):
+ ElfType.__init__(self, verdef, node)
+
+
+class ElfVernaux(ElfType):
+ """A representation of an ELF Vernaux type."""
+
+ fields = [
+ ('vna_hash', do_long, "I", "I"),
+ ('vna_flags', do_long, "H", "H"),
+ ('vna_other', do_long, "H", "H"),
+ ('vna_name', do_long, "I", "I"),
+ ('vna_next', do_long, "I", "I")
+ ]
+
+ def __init__(self, vernaux, node):
+ ElfType.__init__(self, vernaux, node)
+
+class ElfVerneed(ElfType):
+ """A representation of an ELF Verneed type."""
+
+ fields = [
+ ('vn_version', do_long, "H", "H"),
+ ('vn_cnt', do_long, "H", "H"),
+ ('vn_file', do_long, "I", "I"),
+ ('vn_aux', do_long, "I", "I"),
+ ('vn_next', do_long, "I", "I")
+ ]
+
+ def __init__(self, verneed, node):
+ ElfType.__init__(self, verneed, node)
+
+
+#
+# Aggregates
+#
+
+class ElfPhdrTable:
+ """A representation of an ELF Program Header Table.
+
+ A program header table is a list of program header entry sections.
+ """
+
+ def __init__(self, phdr):
+ """Initialize a program header table object.
+
+ Argument 'phdr' is a list of parsed ElfPhdr objects.
+ """
+
+ self.pht_data = []
+ for ph in phdr:
+ if type(ph) == types.DictType:
+ ph = ElfPhdr(ph)
+ elif not isinstance(ph, ElfPhdr):
+ raise ElfError(ph.node,
+ "Program Header Table "
+ "contains non header data.")
+ self.pht_data.append(ph)
+
+ def bits(self, formatchar, elfcla...
[truncated message content] |
|
From: <jk...@us...> - 2008-03-31 06:33:18
|
Revision: 1
http://elftoolchain.svn.sourceforge.net/elftoolchain/?rev=1&view=rev
Author: jkoshy
Date: 2008-03-30 23:33:13 -0700 (Sun, 30 Mar 2008)
Log Message:
-----------
Initial repository layout.
Added Paths:
-----------
projects/
projects/ar/
projects/ar/branches/
projects/ar/tags/
projects/ar/trunk/
projects/elf-tutorial/
projects/elf-tutorial/branches/
projects/elf-tutorial/tags/
projects/elf-tutorial/trunk/
projects/libelf/
projects/libelf/branches/
projects/libelf/tags/
projects/libelf/trunk/
projects/libelf-test-suite/
projects/libelf-test-suite/branches/
projects/libelf-test-suite/tags/
projects/libelf-test-suite/trunk/
projects/size/
projects/size/branches/
projects/size/tags/
projects/size/trunk/
projects/strings/
projects/strings/branches/
projects/strings/tags/
projects/strings/trunk/
users/
users/jkoshy/
users/kaiwang27/
users/yganag/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|