1 #------------------------------------------------------------------------------
4 # Yann Rouillard (yann@pleiades.fr.eu.org)
5 # This code is in the public domain
6 #------------------------------------------------------------------------------
8 import unittest2
as unittest
13 from utils
import setup_syspath
; setup_syspath()
14 from elftools
.elf
.elffile
import ELFFile
15 from elftools
.elf
.dynamic
import DynamicSection
, DynamicTag
18 class TestDoubleDynstrSections(unittest
.TestCase
):
19 """ This test make sure than dynamic tags
20 are properly analyzed when two .dynstr
21 sections are present in an elf file
27 b
'lib_versioned.so.1',
30 def _test_double_dynstr_section_generic(self
, testfile
):
32 with
open(os
.path
.join('test', 'testfiles_for_unittests', testfile
),
35 for section
in elf
.iter_sections():
36 if isinstance(section
, DynamicSection
):
37 d_tags
= [getattr(x
, x
.entry
.d_tag
[3:].lower())
38 for x
in section
.iter_tags()
39 if x
.entry
.d_tag
in DynamicTag
._HANDLED
_TAGS
]
41 TestDoubleDynstrSections
.reference_data
,
44 self
.fail('No dynamic section found !!')
47 def test_double_dynstr_section(self
):
48 """ First test with the good dynstr section first
50 self
._test
_double
_dynstr
_section
_generic
(
51 'lib_with_two_dynstr_sections.so.1.elf')
53 def test_double_dynstr_section_reverse(self
):
54 """ Second test with the good dynstr section last
56 self
._test
_double
_dynstr
_section
_generic
(
57 'lib_with_two_dynstr_sections_reversed.so.1.elf')
60 if __name__
== '__main__':