aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-03-04 15:26:00 +1030
committerAlan Modra <amodra@gmail.com>2020-03-04 15:31:03 +1030
commit233bf4f847b136705247e2f7f11bae41c72448a4 (patch)
tree5bf74dab37da45fc4991e9808561bfa77579bbd6 /bfd/elf.c
parent1039fd9ac2a57b7634f60a66ea51e64f5ff69251 (diff)
downloadgdb-233bf4f847b136705247e2f7f11bae41c72448a4.zip
gdb-233bf4f847b136705247e2f7f11bae41c72448a4.tar.gz
gdb-233bf4f847b136705247e2f7f11bae41c72448a4.tar.bz2
sh_addralign inconsistent with sh_addr
The ELF gABI says in part of sh_addralign: "The value of sh_addr must be congruent to 0, modulo the value of sh_addralign." * elf.c (elf_fake_sections): Ensure sh_addralign is such that sh_addr mod sh_addalign is zero.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index fcd84d2..c4d6718 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3192,6 +3192,7 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
unsigned int sh_type;
const char *name = asect->name;
bfd_boolean delay_st_name_p = FALSE;
+ bfd_vma mask;
if (arg->failed)
{
@@ -3291,7 +3292,10 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
arg->failed = TRUE;
return;
}
- this_hdr->sh_addralign = (bfd_vma) 1 << asect->alignment_power;
+ /* Set sh_addralign to the highest power of two given by alignment
+ consistent with the section VMA. Linker scripts can force VMA. */
+ mask = ((bfd_vma) 1 << asect->alignment_power) | this_hdr->sh_addr;
+ this_hdr->sh_addralign = mask & -mask;
/* The sh_entsize and sh_info fields may have been set already by
copy_private_section_data. */