aboutsummaryrefslogtreecommitdiff
path: root/binutils
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 /binutils
parente547c119d043f2ecffb70452020ab9150d083a91 (diff)
downloadbinutils-276da9b31bd6e3eb8d1dd814c867266f59f29093.zip
binutils-276da9b31bd6e3eb8d1dd814c867266f59f29093.tar.gz
binutils-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 'binutils')
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/readelf.c8
2 files changed, 13 insertions, 2 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 32df4b9..eab6830 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-24 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/22444
+ * readelf.c (process_notes_at): Use ELF_NOTE_DESC_OFFSET to get
+ the offset of the note descriptor. Use ELF_NOTE_NEXT_OFFSET to
+ get the offset of the next note entry.
+
2017-11-23 Pavel I. Kryukov <kryukov@frtk.ru>
PR 22485
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 5944ebe..739367d 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -17969,9 +17969,13 @@ process_notes_at (Filedata * filedata,
inote.namesz = BYTE_GET (external->namesz);
inote.namedata = external->name;
inote.descsz = BYTE_GET (external->descsz);
- inote.descdata = inote.namedata + align_power (inote.namesz, 2);
+ inote.descdata = ((char *) external
+ + ELF_NOTE_DESC_OFFSET (inote.namesz,
+ section->sh_addralign));
inote.descpos = offset + (inote.descdata - (char *) pnotes);
- next = inote.descdata + align_power (inote.descsz, 2);
+ next = ((char *) external
+ + ELF_NOTE_NEXT_OFFSET (inote.namesz, inote.descsz,
+ section->sh_addralign));
}
else
{