Section alignment not set when libbfd is built for all targets
Anthony DeRosa
anthony@ransomed.us
Fri Mar 30 03:23:00 GMT 2012
Hello all,
I am trying to build libbfd.a for *all* targets using the following commands:
tar -xjf binutils-2.21.1a.tar.bz2
cd binutils-2.21.1/bfd/
./configure --enable-targets=all --enable-64-bit-bfd
make
The build completes successfully, and I am able to link against the library.
The problem is, when I dump the section information of a given elf,
the alignment_power field of all sections is always zero (0). (Note
the other section fields I have checked are correct, i.e., vma, lma,
name, size, etc.).
This problem does not happen when I link with a version of libbfd that
was built as part of binutils with a specific target (or use the
libbfd installed on my operating system).
Am I building incorrectly?
Below is a very simple test program that demonstrates the problem.
Usage is: ./program_below <some_elf>
-------------------------------------------
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <bfd.h>
int
main (int argc, char **argv)
{
bfd *abfd;
char *filename = NULL;
char **matching;
asection* section;
if (argc < 2) {
exit(1);
}
filename = argv[1];
abfd = bfd_openr (filename, NULL);
if (abfd == NULL) {
printf("Failed to open\n");
exit(1);
}
if (!bfd_check_format_matches (abfd, bfd_object, &matching)) {
if (bfd_get_error () == bfd_error_file_ambiguously_recognized) {
//list_matching_formats (matching);
free (matching);
exit(1);
}
}
section = abfd->sections;
while (section != NULL) {
printf("%s 2**%u\n", section->name, section->alignment_power);
section = section->next;
}
return 0;
}
-------------------------------------------
Thanks,
Anthony
More information about the Binutils
mailing list