Skip to content

Commit a8f8cef

Browse files
committed
Renaming things.
This PR forfeits our previous awkward naming scheme, where segments were sections, sections were segments and regions were sections. No need to understand the above anymore. Now segments are segments. Sections are sections. Symbols are symbols. For those who adopted the previous scheme, this renaming will do the following: ``` s/section/segment s/region/section s/sym/symbol ```
1 parent 2b0c68a commit a8f8cef

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
2828
``disasm`` is a swiss knife for disassembling things. It takes either a
2929
string object, or something returned by an ``image`` function, e.g.,
30-
images, sections and symbols.
30+
images, segments and symbols.
3131
3232
``disasm`` function returns a generator yielding instances of class
3333
``Insn`` defined in module :mod:`asm`. It has the following attributes:
@@ -69,9 +69,9 @@
6969
* addr_size
7070
* endian
7171
* file (file name)
72-
* sections
72+
* segments
7373
74-
Sections is a list of instances of ``Section`` class, that also has a
74+
Segments is a list of instances of ``Segment`` class, that also has a
7575
``get_symbol`` function and the following attributes:
7676
7777
* name

bap.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,27 +123,27 @@ class Image(Resource):
123123
def __init__(self, ident, bap):
124124
super(Image,self).__init__('image', ident, bap)
125125

126-
def load_sections(self):
127-
ss = self.get('sections')
128-
self.sections = [Section(s, self) for s in ss]
126+
def load_segments(self):
127+
ss = self.get('segments')
128+
self.segments = [Segment(s, self) for s in ss]
129129

130130
def get_symbol(self, name, d=None):
131-
for sec in self.sections:
131+
for sec in self.segments:
132132
sym = sec.get_symbol(name, d)
133133
if sym is not d:
134134
return sym
135135
return d
136136

137137
def __getattr__(self, name):
138-
if name == 'sections':
139-
self.load_sections()
140-
return self.sections
138+
if name == 'segments':
139+
self.load_segments()
140+
return self.segments
141141
else:
142142
return self.get(name)
143143

144-
class Section(Resource):
144+
class Segment(Resource):
145145
def __init__(self, ident, parent):
146-
super(Section, self).__init__('section', ident, parent.bap)
146+
super(Segment, self).__init__('segment', ident, parent.bap)
147147
self.parent = parent
148148

149149
def load_symbols(self):
@@ -362,8 +362,8 @@ def demo_chunk():
362362
def demo_image():
363363
img = image("coreutils_O0_ls")
364364
print "Arch: {1}".format(img.name, img.arch)
365-
print "Sections:"
366-
for sec in img.sections:
365+
print "Segments:"
366+
for sec in img.segments:
367367
print "\t{0}\t{1}".format(sec.name, "".join(sec.perm))
368368
print "\t\tSymbols:"
369369
for sym in sec.symbols:

0 commit comments

Comments
 (0)