aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChristian Eggers <ceggers@gmx.de>2020-03-02 20:17:00 +0000
committerAlan Modra <amodra@gmail.com>2020-03-13 15:48:01 +1030
commit666318230c54a348763927c80d085542d9890c42 (patch)
tree8156ad937b488fb6a4377ade6beb0f1db36b0b7d /include
parent502794d4321dc17d5c9fb591bedc8761118b2943 (diff)
downloadgdb-666318230c54a348763927c80d085542d9890c42.zip
gdb-666318230c54a348763927c80d085542d9890c42.tar.gz
gdb-666318230c54a348763927c80d085542d9890c42.tar.bz2
Fix several mix up between octets and bytes in ELF program headers
Fixes additional locations not handled in the first patch. When converting between addresses in ELF headers [octets] and bfd LMA/VMA [bytes], the number of octets per byte needs to be incorporated. include/ * bfdlink.h (struct bfd_link_order): Add unit (bytes/octets) to offset and size members. * elf/internal.h (struct elf_internal_phdr): Likewise for p_align member. (struct elf_segment_map): Likewise for p_paddr and p_size members bfd/ * bfd.c (bfd_record_phdr): New local "opb". Fix assignment of "p_paddr" from "at". * elfcode.h (bfd_from_remote_memory): Add units to several parameters. New local "opb". Fix usage of p_align. Fix calculation of "localbase" from "ehdr_vma" and "p_vaddr". Fix call of target_read_memory. * elflink.c (elf_fixup_link_order): Fix scope of "s" local. Fix calculation of "offset" and "output_offset". (bfd_elf_final_link): New local "opb". Fix calculation of "size" from "offset" and fix calculation of "end" from "vma+size". Fix comparison between "sh_addr" and "vma"/"output_offset". (bfd_elf_discard_info): Fix calculation of "eh_alignment". * elf-bfd.h (struct elf_link_hash_table): Add unit to tls_size member. * elf.c (_bfd_elf_map_sections_to_segments): Add unit (bytes/ octets) to "wrap_to2 and "phdr_size" locals. Fix calculation of "wrap_to" value. Add unit (bytes) to phdr_lma variable. Fix assignment of p_paddr from phdr_lma. Fix comparison between "lma+size" and "next->lma". (elf_sort_segments): Fix assignment from p_paddr to lma. (assign_file_positions_for_load_sections): Add unit (bytes) to local "align". Fix calculation of local "off_adjust". Fix calculation of local "filehdr_vaddr". (assign_file_positions_for_non_load_sections): New local "opb". Fix calculation of "end" from "p_size". Fix comparison between "vma+SECTION_SIZE" and "start". Fix calculation of "p_memsz" from "end" and "p_vaddr". (rewrite_elf_program_header): Fix comparison between p_vaddr and vma. Fix assignment to p_paddr from lma. Fix comparison between p_paddr and lma. Fix assignment to p_paddr from lma. * merge.c (sec_merge_emit): New local "opb". Convert "alignment_power" to octets. (_bfd_add_merge_section): New locals "alignment_power" and "opb". Fix comparison between "alignment_power" and "sizeof(align)". (_bfd_merge_sections): New local "opb". Divide size by opb before checking align mask.
Diffstat (limited to 'include')
-rw-r--r--include/ChangeLog9
-rw-r--r--include/bfdlink.h4
-rw-r--r--include/elf/internal.h7
3 files changed, 15 insertions, 5 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index aa2c551..2fefb46 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,5 +1,14 @@
2020-03-13 Christian Eggers <ceggers@gmx.de>
+ * bfdlink.h (struct bfd_link_order): Add unit (bytes/octets) to
+ offset and size members.
+ * elf/internal.h (struct elf_internal_phdr): Likewise for
+ p_align member.
+ (struct elf_segment_map): Likewise for p_paddr and p_size
+ members
+
+2020-03-13 Christian Eggers <ceggers@gmx.de>
+
* elf/internal.h (struct elf_internal_phdr): Add unit (octets)
to several member field comments.
(Elf_Internal_Shdr): likewise.
diff --git a/include/bfdlink.h b/include/bfdlink.h
index 8d85530..40a6d4d 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -801,9 +801,9 @@ struct bfd_link_order
struct bfd_link_order *next;
/* Type of link_order. */
enum bfd_link_order_type type;
- /* Offset within output section. */
+ /* Offset within output section in bytes. */
bfd_vma offset;
- /* Size within output section. */
+ /* Size within output section in octets. */
bfd_size_type size;
/* Type specific information. */
union
diff --git a/include/elf/internal.h b/include/elf/internal.h
index d626ade..9692028 100644
--- a/include/elf/internal.h
+++ b/include/elf/internal.h
@@ -91,7 +91,8 @@ struct elf_internal_phdr {
bfd_vma p_paddr; /* Segment physical address in octets. */
bfd_vma p_filesz; /* Segment size in file in octets. */
bfd_vma p_memsz; /* Segment size in memory in octets. */
- bfd_vma p_align; /* Segment alignment, file & memory. */
+ bfd_vma p_align; /* Segment alignment in bytes, file
+ & memory */
};
typedef struct elf_internal_phdr Elf_Internal_Phdr;
@@ -266,13 +267,13 @@ struct elf_segment_map
unsigned long p_type;
/* Program segment flags. */
unsigned long p_flags;
- /* Program segment physical address. */
+ /* Program segment physical address in octets. */
bfd_vma p_paddr;
/* Program segment virtual address offset from section vma in bytes. */
bfd_vma p_vaddr_offset;
/* Program segment alignment. */
bfd_vma p_align;
- /* Segment size in file and memory */
+ /* Segment size in file and memory in octets. */
bfd_vma p_size;
/* Whether the p_flags field is valid; if not, the flags are based
on the section flags. */