diff options
author | Mike Frysinger <vapier@gentoo.org> | 2013-01-02 18:27:15 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2013-01-02 18:27:15 +0000 |
commit | 8c695fa96731a37a3ac593294b4387dc4b5a55f1 (patch) | |
tree | 821db10710c28e04a4d0398bdaf14a67a7105cdf | |
parent | Version bump to latest. Drop older. (diff) | |
download | historical-8c695fa96731a37a3ac593294b4387dc4b5a55f1.tar.gz historical-8c695fa96731a37a3ac593294b4387dc4b5a55f1.tar.bz2 historical-8c695fa96731a37a3ac593294b4387dc4b5a55f1.zip |
Add dynamic tag support as pax-utils/lddtree uses it.
Package-Manager: portage-2.2.0_alpha144/cvs/Linux x86_64
Manifest-Sign-Key: 0xFB7C4156
-rw-r--r-- | dev-python/pyelftools/ChangeLog | 11 | ||||
-rw-r--r-- | dev-python/pyelftools/Manifest | 31 | ||||
-rw-r--r-- | dev-python/pyelftools/files/pyelftools-0.20-dyntags-1.patch | 266 | ||||
-rw-r--r-- | dev-python/pyelftools/files/pyelftools-0.20-dyntags-2.patch | 94 | ||||
-rw-r--r-- | dev-python/pyelftools/pyelftools-0.20-r1.ebuild | 31 |
5 files changed, 417 insertions, 16 deletions
diff --git a/dev-python/pyelftools/ChangeLog b/dev-python/pyelftools/ChangeLog index 548d8019426b..adf7cef03c58 100644 --- a/dev-python/pyelftools/ChangeLog +++ b/dev-python/pyelftools/ChangeLog @@ -1,3 +1,10 @@ # ChangeLog for dev-python/pyelftools -# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/pyelftools/ChangeLog,v 1.1 2012/11/01 05:44:11 vapier Exp $ +# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/dev-python/pyelftools/ChangeLog,v 1.2 2013/01/02 18:27:04 vapier Exp $ +*pyelftools-0.20-r1 (02 Jan 2013) + + 02 Jan 2013; Mike Frysinger <vapier@gentoo.org> + +files/pyelftools-0.20-dyntags-1.patch, + +files/pyelftools-0.20-dyntags-2.patch, +pyelftools-0.20-r1.ebuild: + Add dynamic tag support as pax-utils/lddtree uses it. + diff --git a/dev-python/pyelftools/Manifest b/dev-python/pyelftools/Manifest index e66e385c512c..6161abddc710 100644 --- a/dev-python/pyelftools/Manifest +++ b/dev-python/pyelftools/Manifest @@ -1,24 +1,27 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 +AUX pyelftools-0.20-dyntags-1.patch 8567 SHA256 0481450245d5c0fe9893c2490f7ebd6782b16f17eb79a3206907f2bd2caacfa4 SHA512 9233f132f5a8dd2f2bd1b06526471c5ed85fad5fc9d8e89961d4ae18efb49285a5ce820d787dc40c821d85d81ddabe5fde9442ad90c84b5ad394b8fbab8c06c8 WHIRLPOOL 324b36548c1f9e6b20d42c316fd35a1d5940a583084c20f5b6aeb1663b93368676cbc6467f37445ed5b61750bb2f1589c2201c2e80244213f79b71d1b1a90824 +AUX pyelftools-0.20-dyntags-2.patch 3414 SHA256 980cefbe219a043ef327952657317d1ff36b10e9acd6de20bad61fc906e13aeb SHA512 76177839eb64b3ab58c22caf83568a51e13429af0df4a20ce28599d0e3d0a58f5d692f9c5b84724aa8770d23245dda9f41d0f5aecae7c2bf2f59f8b59d5821ba WHIRLPOOL e7b2b363f58115ded30fbc2d5f8d0f8da96db52308f628f7da9bfec2e7340faa51f155d435305bc5e576c0d638177035b4a2bc1b5682f38c6a918779936a8242 DIST pyelftools-0.20.tar.gz 278640 SHA256 d02e40a841a8cc38d78cdea8e497f601969e7270ebe00c7e671a3ce73f1cdf45 SHA512 41ca795c0dc84afb4bc6d58ccafc19690bc76ad0aeeb72d3d4edb8a4647ffccfd0b904ceb406f4db8d360f5d701c5f2c5a85ea0a0c6e507de28560dab9837071 WHIRLPOOL 8667f67080530222953e2fb485e418a52c61a49b5e4a0c74e957d7b61844b462b8e2976cc06d773a2ee86826c4c33574b71e82b617c7c274240dc199cc5db7fa +EBUILD pyelftools-0.20-r1.ebuild 913 SHA256 4c3a7821c19d17137ed761e43409e316aef05fd808770a3aa77abfc237e4c8cd SHA512 5d3e0bb4c824bdec34d2fd87b1d0e8156fa9e8de390ce3539023c022bf82c8625104e43fb2cc28c35d97e4c88c08f08956a13298c12e8941e46ce91b3f183509 WHIRLPOOL 7e272099da4befeaa099a2829fc19fb9742d830e83ff0ef554b76faf76a2cb1d9f7a30058d1a9bcf15db3f017be9bd71bb8d83aa83f41250bb2a5ee6e9fd0eb4 EBUILD pyelftools-0.20.ebuild 715 SHA256 effe5f07fb720ecb8c3ddcc6ce9f737d83ebda2dc8c257948db656d7c0dad543 SHA512 64f6d1663161c002fab1a1b5cb4bd673957f1c22f0697fe06c0bd03be96f3a9592f13efe8ccfcb0aa83c7ddfc5a8c5a796f52e0f4a0a237b734006d5319e14a2 WHIRLPOOL bb3fcbc6e798a16a9f824a6a10b0d87db99f0a11a5a9050d0b39771ac33ebd1d203c0c56e9261f5e0b06a73b5641c810cf74206d7d2570f78f4ca2b2dc233311 -MISC ChangeLog 214 SHA256 01f0e81f19558ca1f7b209a41ff39d4d6486f3f824f0ff24dcce5342759ee61d SHA512 b39c479753dca2423a0b226f3cd489856be6c518d08e3e66f84d383dd3870476f57a64f4f44f9e230d8f77bbf1d4d36c302384e99bca688b55b84ef231fbfdbb WHIRLPOOL bccbe3d3d3f1e94bbff4bd4bab39bc73373baa24eba45f00da75ea1b56d314e5a93817afb63caededf749798cd02e5252fafe54acc8cd0b2265789860cd5a5e8 +MISC ChangeLog 468 SHA256 204e7d5b673c431f95eb2323247b0e8aeda9aae6266da6ef4dd34f7a5bf30a4e SHA512 54e1d81d5ff98b71885c685e33c2d95c7b19492bf02c584211f6807622f0ea6d37f26c06e4f5d94c5175f72d220ac3e22b9c7501e2260210c0b56376cf9987ee WHIRLPOOL 8212983f918b147c9cb3c537b8d4ac34ebacfe124304a988def157798761eb5cec0af27f6883bdcb198c4d6c9303d5a4eeac2692fd144446fd3ef94857781380 MISC metadata.xml 293 SHA256 b301f23c0997794de6a8a6c54c6afcd268f8837f886d56ccf3e6f22a542da52f SHA512 0e43ae1f5ed9ebbcc434950e6264964b9e01e181b95d6c72f4b5ecfccd65093fc4f774e4f8d9267bb423622309fc88560a7ede22bb514a4b7de404000fa49d2a WHIRLPOOL fca6f65b4a6ccfeab06ff53eaab067d45fd3f35b35a7f8ffbfb5f9993b2d461c3fc6886c502a8307d9f2100860f86a7b7e968c3eb85167e8ea45c1f53a07e880 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) -iQIcBAEBCAAGBQJQkgwwAAoJELEHsLL7fEFWWusP/3gkDRARV9ryY0SF7MlV/nCZ -UYoJ9MjRjhB49wvgU9ig4NCuWzgS+FZMlxVVornCWEg+osxj5VwSRgF2uzxZz8sQ -j2RSAbG5o78jBHZSvlLsCk/+hRXbuVF2103KiQ8ooOz9uIW026hcQGGWHVA0UMx0 -x/MuhqmkrxMlityEYfrcznRHBXrWGW7w2Zi48ySAL67nN76ky7l7W7P6l7pcmbo1 -zaWHcxeMjQ/ZeHOb6x9KQrrJ5L64ihee27hF9mcNCmjljtDEVvo0prOGBFBjDFQj -jPpLErzDbxUhaqgAWYee3/jrZ+8jfZJiO5t3j5Qbw1W3f2aCEaVVlR4yKQTk2xvu -XNjRKN5bI006f5KFnjj/BXm5GvrQ/w1594KZnyM8AOGv56uXlkmO7JB+lJDQF9zL -m7TL6Fsps6Af9W91eeSCvqz+rn8Oksr97DRVVs9x2GA3RC3OGkwSaLVJpQhwsJv0 -NkpnkVjILWUy4oN5mmXP31vNfIOZjmsYiMM7D3ngEzWgdUYsUID/CrbRv7I/+gua -NfhmhqmPxumhNjzu3o4fmXndNI0HCyb19vp6V+/afYkEZsgfSyJhJ/Ll41c85dvo -qaqR1W8+Oih56K91ayAWP4VGHJWorCEhpr+yaxioESWuaOtImG8PawDtlcVIUSI4 -NsVjUUqa7/JhrXmYSj20 -=d6hJ +iQIcBAEBCAAGBQJQ5HxlAAoJELEHsLL7fEFW2ZYQAKAk3Gt5aeWPwTduWYksI/aH +llbqbtuX6XgMEKnx1Oi8lZFysx6Nkbc504u/lU8laQ5dxZy1C0pzrRRQaFhFOMna +4u2Ij+9cx+cMB7vrL/dTBBbpuNAvxGj2mIXX7pPhWxiJExG4HiPOZ8CEPzxUsjUQ +EbzFVSNi6Wafq0aM2vL3IiTXLyRppwhx6O02gbWYY2VY17+PbjUoprYZNo3rybvI +fj6Gu81ZTrDbYOmKTXNpDlqHLUA8w4dqYnpY6enc6CrO3Qax5K9k0ectp++U240C +RleJUdOpbcahYLMyIuKpcxe1FsZgOx/DkXSMzkWLbneybdoX3XC7gKhhSLo6tNfr +hpCry46Kli0TsoD22kkSFH0xGR7oHr1YglIjWayw0kJ28mh4sKCwfQtreofnwygp +pc5IYO5m7ScR0BvnQA3tYCsMBo+FPABh8FzEYtjXtZUTW91Mjm3E4hwkWjIpXRAb +MkKKsImKHvrRaVXQ2qvPED5fhM+IScY9BGFE6PNx2lnjgCdIDOBURie2oEYZ6UAz +Zf62fkmLA5zmMnsYrJgO/9rNV1YYIrHVFFiFLEmckv5REb4ZZWuUfVOs8bWBsNWT +Sr197ZR0a6ERTcectVo5CuUyxuLDrUvUT4gugELAHk0MEy912XByv+zjUosZLK6S +Im3r7DaFGBBh20WsIL5k +=j95f -----END PGP SIGNATURE----- diff --git a/dev-python/pyelftools/files/pyelftools-0.20-dyntags-1.patch b/dev-python/pyelftools/files/pyelftools-0.20-dyntags-1.patch new file mode 100644 index 000000000000..b86720ae3db7 --- /dev/null +++ b/dev-python/pyelftools/files/pyelftools-0.20-dyntags-1.patch @@ -0,0 +1,266 @@ +# HG changeset patch +# User Mike Frysinger <vapier@gentoo.org> +# Date 1352755639 18000 +# Node ID a9c9b2f9ec964e6750dd6f9a96767fe2e9201d85 +# Parent f3408c7b954910aa3a58e88196efba4954c0cc55 +add support for parsing of the dynamic section/segment and its tags + +diff -r f3408c7b9549 -r a9c9b2f9ec96 elftools/elf/dynamic.py +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/elftools/elf/dynamic.py Mon Nov 12 16:27:19 2012 -0500 +@@ -0,0 +1,115 @@ ++#------------------------------------------------------------------------------- ++# elftools: elf/dynamic.py ++# ++# ELF Dynamic Tags ++# ++# Mike Frysinger (vapier@gentoo.org) ++# This code is in the public domain ++#------------------------------------------------------------------------------- ++from .sections import Section ++from .segments import Segment ++from ..common.utils import struct_parse ++ ++from enums import ENUM_D_TAG ++ ++ ++class DynamicTag(object): ++ """ Dynamic Tag object - representing a single dynamic tag entry from a ++ dynamic section. ++ ++ Similarly to Section objects, allows dictionary-like access to the ++ dynamic tag. ++ """ ++ def __init__(self, entry, elffile): ++ self.entry = entry ++ if entry.d_tag == 'DT_NEEDED' or \ ++ entry.d_tag == 'DT_RPATH' or \ ++ entry.d_tag == 'DT_RUNPATH': ++ dynstr = elffile.get_section_by_name('.dynstr') ++ setattr(self, entry.d_tag[3:].lower(), dynstr.get_string(self.entry.d_val)) ++ ++ def __getitem__(self, name): ++ """ Implement dict-like access to entries ++ """ ++ return self.entry[name] ++ ++ def __repr__(self): ++ return '<DynamicTag (%s): %r>' % (self.entry.d_tag, self.entry) ++ ++ def __str__(self): ++ if self.entry.d_tag == 'DT_NEEDED' or \ ++ self.entry.d_tag == 'DT_RPATH' or \ ++ self.entry.d_tag == 'DT_RUNPATH': ++ s = '"%s"' % getattr(self, self.entry.d_tag[3:].lower()) ++ else: ++ s = '%#x' % self.entry.d_ptr ++ return '<DynamicTag (%s) %s>' % (self.entry.d_tag, s) ++ ++ ++class Dynamic(object): ++ def __init__(self, stream, elffile, position): ++ self._stream = stream ++ self._elffile = elffile ++ self._elfstructs = elffile.structs ++ self._num_tags = -1; ++ self._offset = position ++ self._tagsize = self._elfstructs.Elf_Dyn.sizeof() ++ ++ def iter_tags(self, type=None): ++ """ Yield all tags (limit to |type| if specified) ++ """ ++ offset = self._offset - self._tagsize ++ for i in range(self.num_tags): ++ offset += self._tagsize ++ entry = struct_parse( ++ self._elfstructs.Elf_Dyn, ++ self._stream, ++ stream_pos=offset) ++ if type is not None and entry.d_tag != type: ++ continue ++ yield DynamicTag(entry, self._elffile) ++ ++ def get_tag(self, n): ++ """ Get the tag at index #n from the file (DynamicTag object) ++ """ ++ offset = self._offset + n * self._tagsize ++ entry = struct_parse( ++ self._elfstructs.Elf_Dyn, ++ self._stream, ++ stream_pos=offset) ++ return DynamicTag(entry, self._elffile) ++ ++ @property ++ def num_tags(self): ++ """ Number of dynamic tags in the file ++ """ ++ if self._num_tags != -1: ++ return self._num_tags ++ ++ offset = self._offset ++ while True: ++ entry = struct_parse( ++ self._elfstructs.Elf_Dyn, ++ self._stream, ++ stream_pos=offset) ++ if entry.d_tag == 'DT_NULL': ++ self._num_tags = ((offset - self._offset) // self._tagsize) + 1 ++ break ++ offset += self._tagsize ++ return self._num_tags ++ ++ ++class DynamicSection(Section, Dynamic): ++ """ ELF dynamic table section. Knows how to process the list of tags. ++ """ ++ def __init__(self, header, name, stream, elffile): ++ Section.__init__(self, header, name, stream) ++ Dynamic.__init__(self, stream, elffile, self['sh_offset']) ++ ++ ++class DynamicSegment(Segment, Dynamic): ++ """ ELF dynamic table segment. Knows how to process the list of tags. ++ """ ++ def __init__(self, header, stream, elffile): ++ Segment.__init__(self, header, stream) ++ Dynamic.__init__(self, stream, elffile, self['p_offset']) +diff -r f3408c7b9549 -r a9c9b2f9ec96 elftools/elf/elffile.py +--- a/elftools/elf/elffile.py Thu Jul 05 06:32:09 2012 +0300 ++++ b/elftools/elf/elffile.py Mon Nov 12 16:27:19 2012 -0500 +@@ -13,6 +13,7 @@ + from .structs import ELFStructs + from .sections import ( + Section, StringTableSection, SymbolTableSection, NullSection) ++from .dynamic import DynamicSection, DynamicSegment + from .relocation import RelocationSection, RelocationHandler + from .segments import Segment, InterpSegment + from .enums import ENUM_RELOC_TYPE_i386, ENUM_RELOC_TYPE_x64 +@@ -208,6 +209,8 @@ + segtype = segment_header['p_type'] + if segtype == 'PT_INTERP': + return InterpSegment(segment_header, self.stream) ++ elif segtype == 'PT_DYNAMIC': ++ return DynamicSegment(segment_header, self.stream, self) + else: + return Segment(segment_header, self.stream) + +@@ -241,6 +244,8 @@ + elif sectype in ('SHT_REL', 'SHT_RELA'): + return RelocationSection( + section_header, name, self.stream, self) ++ elif sectype == 'SHT_DYNAMIC': ++ return DynamicSection(section_header, name, self.stream, self) + else: + return Section(section_header, name, self.stream) + +diff -r f3408c7b9549 -r a9c9b2f9ec96 elftools/elf/enums.py +--- a/elftools/elf/enums.py Thu Jul 05 06:32:09 2012 +0300 ++++ b/elftools/elf/enums.py Mon Nov 12 16:27:19 2012 -0500 +@@ -186,6 +186,82 @@ + _default_=Pass, + ) + ++# d_tag ++ENUM_D_TAG = dict( ++ 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_NUM=34, ++ DT_LOOS=0x6000000d, ++ DT_HIOS=0x6ffff000, ++ DT_LOPROC=0x70000000, ++ DT_HIPROC=0x7fffffff, ++ DT_PROCNUM=0x35, ++ DT_VALRNGLO=0x6ffffd00, ++ DT_GNU_PRELINKED=0x6ffffdf5, ++ DT_GNU_CONFLICTSZ=0x6ffffdf6, ++ DT_GNU_LIBLISTSZ=0x6ffffdf7, ++ DT_CHECKSUM=0x6ffffdf8, ++ DT_PLTPADSZ=0x6ffffdf9, ++ DT_MOVEENT=0x6ffffdfa, ++ DT_MOVESZ=0x6ffffdfb, ++ DT_SYMINSZ=0x6ffffdfe, ++ DT_SYMINENT=0x6ffffdff, ++ DT_GNU_HASH=0x6ffffef5, ++ DT_TLSDESC_PLT=0x6ffffef6, ++ DT_TLSDESC_GOT=0x6ffffef7, ++ DT_GNU_CONFLICT=0x6ffffef8, ++ DT_GNU_LIBLIST=0x6ffffef9, ++ DT_CONFIG=0x6ffffefa, ++ DT_DEPAUDIT=0x6ffffefb, ++ DT_AUDIT=0x6ffffefc, ++ DT_PLTPAD=0x6ffffefd, ++ DT_MOVETAB=0x6ffffefe, ++ DT_SYMINFO=0x6ffffeff, ++ DT_VERSYM=0x6ffffff0, ++ DT_RELACOUNT=0x6ffffff9, ++ DT_RELCOUNT=0x6ffffffa, ++ DT_FLAGS_1=0x6ffffffb, ++ DT_VERDEF=0x6ffffffc, ++ DT_VERDEFNUM=0x6ffffffd, ++ DT_VERNEED=0x6ffffffe, ++ DT_VERNEEDNUM=0x6fffffff, ++ DT_AUXILIARY=0x7ffffffd, ++ DT_FILTER=0x7fffffff, ++ _default_=Pass, ++) ++ + ENUM_RELOC_TYPE_i386 = dict( + R_386_NONE=0, + R_386_32=1, +diff -r f3408c7b9549 -r a9c9b2f9ec96 elftools/elf/structs.py +--- a/elftools/elf/structs.py Thu Jul 05 06:32:09 2012 +0300 ++++ b/elftools/elf/structs.py Mon Nov 12 16:27:19 2012 -0500 +@@ -72,6 +72,7 @@ + self._create_shdr() + self._create_sym() + self._create_rel() ++ self._create_dyn() + + def _create_ehdr(self): + self.Elf_Ehdr = Struct('Elf_Ehdr', +@@ -165,6 +166,13 @@ + self.Elf_sxword('r_addend'), + ) + ++ def _create_dyn(self): ++ self.Elf_Dyn = Struct('Elf_Dyn', ++ Enum(self.Elf_sxword('d_tag'), **ENUM_D_TAG), ++ self.Elf_xword('d_val'), ++ Value('d_ptr', lambda ctx: ctx['d_val']), ++ ) ++ + def _create_sym(self): + # st_info is hierarchical. To access the type, use + # container['st_info']['type'] diff --git a/dev-python/pyelftools/files/pyelftools-0.20-dyntags-2.patch b/dev-python/pyelftools/files/pyelftools-0.20-dyntags-2.patch new file mode 100644 index 000000000000..02528a907df0 --- /dev/null +++ b/dev-python/pyelftools/files/pyelftools-0.20-dyntags-2.patch @@ -0,0 +1,94 @@ +# HG changeset patch +# User Mike Frysinger <vapier@gentoo.org> +# Date 1354166686 18000 +# Node ID 94901c23fe58ca227aacadcdc5d7ad3045171b24 +# Parent a9c9b2f9ec964e6750dd6f9a96767fe2e9201d85 +rework dynamic tag walking to avoid doing it twice on the first call to iter_tags + +Based on suggestions from David James + +diff -r a9c9b2f9ec96 -r 94901c23fe58 elftools/elf/dynamic.py +--- a/elftools/elf/dynamic.py Mon Nov 12 16:27:19 2012 -0500 ++++ b/elftools/elf/dynamic.py Thu Nov 29 00:24:46 2012 -0500 +@@ -6,6 +6,8 @@ + # Mike Frysinger (vapier@gentoo.org) + # This code is in the public domain + #------------------------------------------------------------------------------- ++import itertools ++ + from .sections import Section + from .segments import Segment + from ..common.utils import struct_parse +@@ -20,11 +22,12 @@ + Similarly to Section objects, allows dictionary-like access to the + dynamic tag. + """ ++ ++ _HANDLED_TAGS = frozenset(['DT_NEEDED', 'DT_RPATH', 'DT_RUNPATH']) ++ + def __init__(self, entry, elffile): + self.entry = entry +- if entry.d_tag == 'DT_NEEDED' or \ +- entry.d_tag == 'DT_RPATH' or \ +- entry.d_tag == 'DT_RUNPATH': ++ if entry.d_tag in self._HANDLED_TAGS: + dynstr = elffile.get_section_by_name('.dynstr') + setattr(self, entry.d_tag[3:].lower(), dynstr.get_string(self.entry.d_val)) + +@@ -37,9 +40,7 @@ + return '<DynamicTag (%s): %r>' % (self.entry.d_tag, self.entry) + + def __str__(self): +- if self.entry.d_tag == 'DT_NEEDED' or \ +- self.entry.d_tag == 'DT_RPATH' or \ +- self.entry.d_tag == 'DT_RUNPATH': ++ if self.entry.d_tag in self._HANDLED_TAGS: + s = '"%s"' % getattr(self, self.entry.d_tag[3:].lower()) + else: + s = '%#x' % self.entry.d_ptr +@@ -58,16 +59,12 @@ + def iter_tags(self, type=None): + """ Yield all tags (limit to |type| if specified) + """ +- offset = self._offset - self._tagsize +- for i in range(self.num_tags): +- offset += self._tagsize +- entry = struct_parse( +- self._elfstructs.Elf_Dyn, +- self._stream, +- stream_pos=offset) +- if type is not None and entry.d_tag != type: +- continue +- yield DynamicTag(entry, self._elffile) ++ for n in itertools.count(): ++ tag = self.get_tag(n) ++ if type is None or tag.entry.d_tag == type: ++ yield tag ++ if tag.entry.d_tag == 'DT_NULL': ++ break + + def get_tag(self, n): + """ Get the tag at index #n from the file (DynamicTag object) +@@ -86,17 +83,11 @@ + if self._num_tags != -1: + return self._num_tags + +- offset = self._offset +- while True: +- entry = struct_parse( +- self._elfstructs.Elf_Dyn, +- self._stream, +- stream_pos=offset) +- if entry.d_tag == 'DT_NULL': +- self._num_tags = ((offset - self._offset) // self._tagsize) + 1 +- break +- offset += self._tagsize +- return self._num_tags ++ for n in itertools.count(): ++ tag = self.get_tag(n) ++ if tag.entry.d_tag == 'DT_NULL': ++ self._num_tags = n ++ return n + + + class DynamicSection(Section, Dynamic): diff --git a/dev-python/pyelftools/pyelftools-0.20-r1.ebuild b/dev-python/pyelftools/pyelftools-0.20-r1.ebuild new file mode 100644 index 000000000000..e629c7edff22 --- /dev/null +++ b/dev-python/pyelftools/pyelftools-0.20-r1.ebuild @@ -0,0 +1,31 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-python/pyelftools/pyelftools-0.20-r1.ebuild,v 1.1 2013/01/02 18:27:04 vapier Exp $ + +EAPI="4" + +SUPPORT_PYTHON_ABIS="1" + +inherit distutils eutils + +DESCRIPTION="pure-Python library for parsing and analyzing ELF files and DWARF debugging information" +HOMEPAGE="http://pypi.python.org/pypi/pyelftools https://bitbucket.org/eliben/pyelftools" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" + +LICENSE="public-domain" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd" +IUSE="" + +src_prepare() { + epatch "${FILESDIR}"/${P}-dyntags-{1,2}.patch + distutils_src_prepare +} + +src_test() { + local t + # readelf_tests fails + for t in all_unittests examples_test ; do + ./test/run_${t}.py || die + done +} |