Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update qtdis.c to use new versions of binutils #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ install the multiarch version of the libraries:
sudo apt-get install binutils-multiarch-dev
```

On Fedora you can run:
```
sudo dnf install libarchive-devel binutils-devel binutils-*-linux-gnu
```

To build:

```
Expand Down
18 changes: 15 additions & 3 deletions qtdis/qtdis.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ static void build_symtab(bfd *abfd)
if (!(bfd_get_file_flags(abfd) & HAS_SYMS))
return;

nr_syms = bfd_read_minisymbols(abfd, 0, (PTR) &syms, &size);
nr_syms = bfd_read_minisymbols(abfd, 0, (void*) &syms, &size);

if (nr_syms == 0)
nr_syms = bfd_read_minisymbols(abfd, 1, (PTR) &syms, &size);
nr_syms = bfd_read_minisymbols(abfd, 1, (void*) &syms, &size);

symcount = nr_syms;

Expand Down Expand Up @@ -212,6 +212,18 @@ static void print_address(bfd_vma vma, struct disassemble_info *info)
__print_address(vma);
}

static int fprintf_styled(void *, enum disassembler_style, const char* fmt, ...)
{
va_list args;
int r;

va_start(args, fmt);
r = vprintf(fmt, args);
va_end(args);

return r;
}

/*
* The qtrace format writes the instruction in big endian format, but we
* converted it to host endian as we read it. Since we pass the instruction in
Expand Down Expand Up @@ -240,7 +252,7 @@ void disasm(unsigned long ea, uint32_t *buf, unsigned long bufsize)
disassembler_p = print_insn_big_powerpc;
#endif

init_disassemble_info(&info, stdout, (fprintf_ftype)fprintf);
init_disassemble_info(&info, stdout, (fprintf_ftype)fprintf, fprintf_styled);
info.disassembler_options = "power10";
info.print_address_func = print_address;
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
Expand Down