Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pybfd/bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pybfd_openr(PyObject *self, PyObject *args) {
const char* target;

if (PyArg_ParseTuple(args, "ss", &filename, &target)) {
abfd = bfd_openr(filename, NULL);
abfd = bfd_openr(filename, target);

if (!abfd) {
// An error ocurred trying to open the file.
Expand Down Expand Up @@ -191,7 +191,7 @@ pybfd_fdopenr(PyObject *self, PyObject *args) {
int fd;

if (PyArg_ParseTuple(args, "ssi", &filename, &target, &fd)) {
abfd = bfd_fdopenr(filename, NULL, fd);
abfd = bfd_fdopenr(filename, target, fd);

if (!abfd) {
// An error ocurred trying to open the file.
Expand Down
25 changes: 23 additions & 2 deletions pybfd/objdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,26 @@ def do_action(self, parser, namespace, values, option_string):

print "%s %s (%s)" % (parser.prog, __version__, __description__)

print "Architectures:",
for arch in self.bfd.architectures:
print " %s" % arch,
print

print

print "Bfd Targets:",
for target in self.bfd.targets:
print " %s" % target
print " %s" % target,
print


class BfdActionTarget(Action):
def __call__(self, parser, namespace, values, option_string=None):
self.bfd = bfd.Bfd()
if values[0] not in self.bfd.targets:
raise Exception("Invalid bfd target '%s'" % values[0])
namespace.target = values[0]
self.bfd.close()


class BfdActionWithFileParam(Action):
Expand All @@ -64,7 +79,7 @@ def __call__(self, parser, namespace, values, option_string=None):
for fd in values:
try:
# Create a new BFD from the current file descriptor.
self.bfd = bfd.Bfd(fd)
self.bfd = bfd.Bfd(fd, namespace.target)

# Display current filename and corresponding architecture.
print "\n%s: file format %s\n" % \
Expand Down Expand Up @@ -274,6 +289,12 @@ def init_parser():
type=FileType("r"), nargs="+",
help="Display archive header information")

group.add_argument("-b", "--target", # add "-b, --target" to support bfd targets
action=BfdActionTarget,
nargs="+",
default="default",
help="")

group.add_argument("-f", "--file-headers",
action=DumpFileHeadersAction,
type=FileType("r"), nargs="+",
Expand Down