diff options
| author | Ed Maste <emaste@FreeBSD.org> | 2019-06-29 15:27:18 +0000 |
|---|---|---|
| committer | Ed Maste <emaste@FreeBSD.org> | 2019-06-29 15:27:18 +0000 |
| commit | a5b08c1484eac2c6a65e726f550b3189ff84c6c8 (patch) | |
| tree | 01cd9d6d76e2c378b391422460c6f233ead08179 /test/libelf/tset/bin/elfc | |
| parent | 2b92b30119ed91ed88f102ba9ecc40cd1c046a65 (diff) | |
Notes
Diffstat (limited to 'test/libelf/tset/bin/elfc')
| -rwxr-xr-x | test/libelf/tset/bin/elfc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/test/libelf/tset/bin/elfc b/test/libelf/tset/bin/elfc index 98995e820e26c..4c77e4220b18f 100755 --- a/test/libelf/tset/bin/elfc +++ b/test/libelf/tset/bin/elfc @@ -74,7 +74,7 @@ # sections, a section index may be manually specified using a # 'sh_index' pseudo field. # -# $Id: elfc 3614 2018-04-21 19:48:04Z jkoshy $ +# $Id: elfc 3689 2019-02-23 22:50:51Z jkoshy $ version = "%prog 1.0" usage = "usage: %prog [options] [input-file]" @@ -442,6 +442,14 @@ def check_dict(d, l, node=None): raise ElfError(node, "{%s} Unknown key(s) %s" % \ (node.tag, unknown)) +def bounded_value(v, encoding): + """Return the value of 'v' bounded to the maximum size for a type.""" + if encoding == "H": + return (v & 0xFFFF) + elif encoding == "I": + return (v & 0xFFFFFFFF) + return v + # # Helper classes. # @@ -559,8 +567,10 @@ class ElfType: else: n = 3 for t in self.fields: - if t[n] != "": - a.append(getattr(self, t[0])) + field_encoding = t[n] + if field_encoding != "": + v = getattr(self, t[0]) + a.append(bounded_value(v, field_encoding)) return tuple(a) def getfields(self, elfclass): |
