strange OS dependent behavior of bfd_get_flavour()
Peng Yu
pengyu.ut@gmail.com
Fri Apr 30 12:19:21 GMT 2021
On Fri, Apr 30, 2021 at 5:19 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Apr 30 2021, Peng Yu via Binutils wrote:
>
> > Hi,
> >
> > #define PACKAGE 1
> > #define PACKAGE_VERSION 1
> > #include <bfd.h>
> > #include <stdio.h>
> >
> > int main(int argc, char *argv[]) {
> > bfd_init();
> > bfd *bfd_h = bfd_openr(argv[1], 0);
> > printf("bfd_get_flavour(bfd_h) = %d\n", bfd_get_flavour(bfd_h));
> > bfd_close(bfd_h);
> > }
> >
> >
> > For the above C file, it returns the following on macOS.
> >
> > $ ./main.exe test_file
> > bfd_get_flavour(bfd_h) = 17
> >
> > But it returns the following macOS.
> >
> > $ ./main.exe test_file
> > bfd_get_flavour(bfd_h) = 5
>
> You are using NULL as the target, which means the default target.
What is a target? The manual is written confusingly. Does it refer to
what the OS the libbfd program runs? Or the OS the file being analyzed
runs?
https://ftp.gnu.org/old-gnu/Manuals/bfd-2.9.1/html_node/bfd_28.html#SEC101
If the latter, why is it necessary to specify it in bfd_openr()? Why
it can not be derived from the filename argument?
--
Regards,
Peng
More information about the Binutils
mailing list