aboutsummaryrefslogtreecommitdiff
path: root/include/elf
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-11-24 14:49:36 -0800
committerH.J. Lu <hjl.tools@gmail.com>2017-11-24 14:52:15 -0800
commit276da9b31bd6e3eb8d1dd814c867266f59f29093 (patch)
tree1acbee1595881224123021036356e0d43316ccf3 /include/elf
parente547c119d043f2ecffb70452020ab9150d083a91 (diff)
downloadgdb-276da9b31bd6e3eb8d1dd814c867266f59f29093.zip
gdb-276da9b31bd6e3eb8d1dd814c867266f59f29093.tar.gz
gdb-276da9b31bd6e3eb8d1dd814c867266f59f29093.tar.bz2
Re-apply "elf: Properly compute offsets of note descriptor and next note"
CORE PT_NOTE segments may have p_align values of 0 or 1. gABI specifies that PT_NOTE alignment should be aligned to 4 bytes for 32-bit objects and to 8 bytes for 64-bit objects. If segment alignment is less than 4, we use 4 byte alignment.
Diffstat (limited to 'include/elf')
-rw-r--r--include/elf/external.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/elf/external.h b/include/elf/external.h
index d65bae0..eb0a53a 100644
--- a/include/elf/external.h
+++ b/include/elf/external.h
@@ -183,6 +183,22 @@ typedef struct {
char name[1]; /* Start of the name+desc data */
} Elf_External_Note;
+/* Align an address upward to a boundary, expressed as a number of bytes.
+ E.g. align to an 8-byte boundary with argument of 8. */
+#define ELF_ALIGN_UP(addr, boundary) \
+ (((bfd_vma) (addr) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary) -1))
+
+/* Compute the offset of the note descriptor from size of note entry's
+ owner string and note alignment. */
+#define ELF_NOTE_DESC_OFFSET(namesz, align) \
+ ELF_ALIGN_UP (offsetof (Elf_External_Note, name) + (namesz), (align))
+
+/* Compute the offset of the next note entry from size of note entry's
+ owner string, size of the note descriptor and note alignment. */
+#define ELF_NOTE_NEXT_OFFSET(namesz, descsz, align) \
+ ELF_ALIGN_UP (ELF_NOTE_DESC_OFFSET ((namesz), (align)) + (descsz), \
+ (align))
+
/* Relocation Entries */
typedef struct {
unsigned char r_offset[4]; /* Location at which to apply the action */