diff --git a/elf2flt.c b/elf2flt.c index b93aecd..b18e06a 100644 --- a/elf2flt.c +++ b/elf2flt.c @@ -363,7 +363,7 @@ output_relocs ( #endif #if 0 - printf("%s(%d): output_relocs(abs_bfd=%d,synbols=0x%x,number_of_symbols=%d" + printf("%s(%d): output_relocs(abs_bfd=%d,symbols=0x%x,number_of_symbols=%d," "n_relocs=0x%x,text=0x%x,text_len=%d,data=0x%x,data_len=%d)\n", __FILE__, __LINE__, abs_bfd, symbols, number_of_symbols, n_relocs, text, text_len, data, data_len); @@ -424,7 +424,8 @@ output_relocs ( */ if ((!pic_with_got || ALWAYS_RELOC_TEXT) && ((a->flags & SEC_CODE) || - ((a->flags & (SEC_DATA | SEC_READONLY)) == (SEC_DATA | SEC_READONLY)))) + ((a->flags & (SEC_DATA | SEC_READONLY | SEC_RELOC)) == + (SEC_DATA | SEC_READONLY | SEC_RELOC)))) sectionp = text + (a->vma - text_vma); else if (a->flags & SEC_DATA) sectionp = data + (a->vma - data_vma); @@ -1875,7 +1876,9 @@ int main(int argc, char *argv[]) bfd_size_type sec_size; bfd_vma sec_vma; - if (s->flags & SEC_CODE) { + if ((s->flags & SEC_CODE) || + ((s->flags & (SEC_DATA | SEC_READONLY | SEC_RELOC)) == + (SEC_DATA | SEC_READONLY | SEC_RELOC))) { vma = &text_vma; len = &text_len; } else if (s->flags & SEC_DATA) { @@ -1908,9 +1911,13 @@ int main(int argc, char *argv[]) if (verbose) printf("TEXT -> vma=0x%x len=0x%x\n", text_vma, text_len); - /* Read in all text sections. */ + /* Read input sections destined for the text output segment. + * Includes code sections, but also includes read-only relocation + * data sections.*/ for (s = abs_bfd->sections; s != NULL; s = s->next) - if (s->flags & SEC_CODE) + if ((s->flags & SEC_CODE) || + ((s->flags & (SEC_DATA | SEC_READONLY | SEC_RELOC)) == + (SEC_DATA | SEC_READONLY | SEC_RELOC))) if (!bfd_get_section_contents(abs_bfd, s, text + (s->vma - text_vma), 0, bfd_section_size(abs_bfd, s))) @@ -1934,9 +1941,13 @@ int main(int argc, char *argv[]) text_len = data_vma - text_vma; } - /* Read in all data sections. */ + /* Read input sections destined for the data output segment. + * Includes data sections, but not those read-only relocation + * data sections already included in the text output section.*/ for (s = abs_bfd->sections; s != NULL; s = s->next) - if (s->flags & SEC_DATA) + if ((s->flags & SEC_DATA) && + ((s->flags & (SEC_READONLY | SEC_RELOC)) != + (SEC_READONLY | SEC_RELOC))) if (!bfd_get_section_contents(abs_bfd, s, data + (s->vma - data_vma), 0, bfd_section_size(abs_bfd, s)))