glibc/elf
H.J. Lu 8d81ce0c6d Properly compute offsets of note descriptor and next note [BZ #22370]
A note header has 3 4-bytes fields, followed by note name and note
descriptor.  According to gABI, in a note entry, the note name field,
not note name size, is padded for the note descriptor.  And the note
descriptor field, not note descriptor size, is padded for the next
note entry.  Notes are aligned to 4 bytes in 32-bit objects and 8 bytes
in 64-bit objects.

For all GNU notes, the name is "GNU" which is 4 bytes.  They have the
same format in the first 16 bytes in both 32-bit and 64-bit objects.
They differ by note descriptor size and note type.  So far, .note.ABI-tag
and .note.gnu.build-id notes are always aligned to 4 bytes.  The exsting
codes compute the note size by aligning the note name size and note
descriptor size to 4 bytes.  It happens to produce the same value as
the actual note size by luck since the name size is 4 and offset of the
note descriptor is 16.  But it will produce the wrong size when note
alignment is 8 bytes in 64-bit objects.

This patch defines ELF_NOTE_DESC_OFFSET and ELF_NOTE_NEXT_OFFSET to
properly compute offsets of note descriptor and next note.  It uses
alignment of PT_NOTE segment to support both 4-byte and 8-byte note
alignments in 64-bit objects.  To handle PT_NOTE segments with
incorrect alignment, which may lead to an infinite loop, if segment
alignment is less than 4, we treate alignment as 4 bytes since some
note segments have 0 or 1 byte alignment.

	[BZ #22370]
	* elf/dl-hwcaps.c (ROUND): Removed.
	(_dl_important_hwcaps): Replace ROUND with ELF_NOTE_DESC_OFFSET
	and ELF_NOTE_NEXT_OFFSET.
	* elf/dl-load.c (ROUND): Removed.
	(open_verify): Replace ROUND with ELF_NOTE_NEXT_OFFSET.
	* elf/readelflib.c (ROUND): Removed.
	(process_elf_file): Replace ROUND with ELF_NOTE_NEXT_OFFSET.
	* include/elf.h [!_ISOMAC]: Include <libc-pointer-arith.h>.
	[!_ISOMAC] (ELF_NOTE_DESC_OFFSET): New.
	[!_ISOMAC] (ELF_NOTE_NEXT_OFFSET): Likewise.
2017-11-28 09:57:00 -08:00
..
cache.c
chroot_canon.c
circleload1.c
circlemod1.c
circlemod1a.c
circlemod2.c
circlemod2a.c
circlemod3.c
circlemod3a.c
constload1.c
constload2.c
constload3.c
dblload.c
dblloadmod1.c
dblloadmod2.c
dblloadmod3.c
dblunload.c
dep1.c
dep2.c
dep3.c
dep4.c
dl-addr-obj.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-addr.c ld.so: Remove internal_function attribute from various functions 2017-08-13 21:11:54 +02:00
dl-brk.c
dl-cache.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-caller.c
dl-close.c Consolidate link map sorting 2017-11-27 11:37:19 +01:00
dl-conflict.c
dl-debug.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-deps.c Consolidate link map sorting 2017-11-27 11:37:19 +01:00
dl-dst.h
dl-environ.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-error-minimal.c
dl-error-skeleton.c ld.so: Remove internal_function attribute from various functions 2017-08-13 21:11:54 +02:00
dl-error.c
dl-exception.c ld.so: Introduce struct dl_exception 2017-08-10 16:54:57 +02:00
dl-execstack.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-fini.c Consolidate link map sorting 2017-11-27 11:37:19 +01:00
dl-fptr.c
dl-hwcaps.c Properly compute offsets of note descriptor and next note [BZ #22370] 2017-11-28 09:57:00 -08:00
dl-hwcaps.h Make LD_HWCAP_MASK usable for static binaries 2017-06-07 11:11:40 +05:30
dl-init.c _dl_init: Remove internal_function attribute 2017-08-14 15:08:48 +02:00
dl-iteratephdr.c Move hidden_proto (__dl_iterate_phdr) to include/link.h [BZ #18822] 2017-10-01 16:09:38 -07:00
dl-libc.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-load.c Properly compute offsets of note descriptor and next note [BZ #22370] 2017-11-28 09:57:00 -08:00
dl-load.h
dl-lookup.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-machine-reject-phdr.h
dl-map-segments.h Check for __mprotect failure in _dl_map_segments [BZ #20831] 2017-04-09 23:34:33 +00:00
dl-minimal.c ld.so: Consolidate 2 strtouls into _dl_strtoul [BZ #21528] 2017-06-08 12:52:42 -07:00
dl-misc.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-object.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-open.c Consolidate link map sorting 2017-11-27 11:37:19 +01:00
dl-origin.c
dl-profile.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-profstub.c
dl-reloc.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-runtime.c PowerPC64 ELFv2 PPC64_OPT_LOCALENTRY 2017-06-14 10:47:25 +09:30
dl-sbrk.c
dl-scope.c
dl-sort-maps.c Consolidate link map sorting 2017-11-27 11:37:19 +01:00
dl-support.c ld.so: Add architecture specific fields 2017-11-13 08:02:52 -08:00
dl-sym.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-symaddr.c
dl-sysdep-open.h
dl-sysdep.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-tls.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-trampoline.c
dl-tunable-types.h tunables: Add support for tunables of uint64_t type 2017-05-17 13:11:55 +05:30
dl-tunables.c Fix range check in do_tunable_update_val 2017-09-27 02:44:09 +05:30
dl-tunables.h tunables, aarch64: New tunable to override cpu 2017-06-30 22:58:39 +05:30
dl-tunables.list Add per-thread cache to malloc 2017-07-06 13:37:30 -04:00
dl-unmap-segments.h
dl-version.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
dl-writev.h
do-rel.h
dynamic-link.h elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
elf.h Add NT_GNU_PROPERTY_TYPE_0 macros 2017-08-18 08:50:42 -07:00
enbl-secure.c
failobj.c
filter.c
filtmod1.c
filtmod2.c
firstobj.c
gen-trusted-dirs.awk
genrtldtbl.awk
get-dynamic-info.h Remove header file inclusion guard from elf/get-dynamic-info.h 2017-03-02 17:28:41 +01:00
global.c
globalmod1.c
ifuncdep1.c
ifuncdep1pic.c
ifuncdep2.c
ifuncdep2pic.c
ifuncdep5.c
ifuncdep5pic.c
ifuncmain1.c
ifuncmain1pic.c
ifuncmain1picstatic.c
ifuncmain1pie.c
ifuncmain1static.c
ifuncmain1staticpic.c
ifuncmain1staticpie.c
ifuncmain1vis.c
ifuncmain1vispic.c
ifuncmain1vispie.c
ifuncmain2.c
ifuncmain2pic.c
ifuncmain2picstatic.c
ifuncmain2static.c
ifuncmain3.c
ifuncmain4.c
ifuncmain4picstatic.c
ifuncmain4static.c
ifuncmain5.c
ifuncmain5pic.c
ifuncmain5picstatic.c
ifuncmain5pie.c
ifuncmain5static.c
ifuncmain5staticpic.c
ifuncmain6pie.c
ifuncmain7.c
ifuncmain7pic.c
ifuncmain7picstatic.c
ifuncmain7pie.c
ifuncmain7static.c
ifuncmod1.c
ifuncmod3.c
ifuncmod5.c
ifuncmod6.c
initfirst.c
interp.c
lateglobal.c
ldconfig.c Assume that _DIRENT_HAVE_D_TYPE is always defined. 2017-10-30 15:48:33 +01:00
ldd.bash.in ldd: never run file directly 2017-08-16 15:59:55 +02:00
link.h
loadfail.c
loadtest.c Fix elf/loadtest.c build with GCC 8. 2017-06-27 17:52:42 +00:00
ltglobmod1.c
ltglobmod2.c
Makefile Consolidate link map sorting 2017-11-27 11:37:19 +01:00
multiload.c
neededobj1.c
neededobj2.c
neededobj3.c
neededobj4.c
neededobj5.c
neededobj6.c
neededtest2.c
neededtest3.c
neededtest4.c
neededtest.c
next.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
nextmod1.c
nextmod2.c
nodel2mod1.c
nodel2mod2.c
nodel2mod3.c
nodelete2.c
nodelete.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
nodelmod1.c
nodelmod2.c
nodelmod3.c
nodelmod4.c
nodlopen2.c
nodlopen.c
nodlopenmod2.c
nodlopenmod.c
noload.c
order2.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
order2mod1.c
order2mod2.c
order2mod3.c
order2mod4.c
order.c
origtest.c
pathoptobj.c
pldd-xx.c
pldd.c
preloadtest.c
readelflib.c Properly compute offsets of note descriptor and next note [BZ #22370] 2017-11-28 09:57:00 -08:00
readlib.c
reldep2.c
reldep3.c
reldep4.c
reldep4mod1.c
reldep4mod2.c
reldep4mod3.c
reldep4mod4.c
reldep5.c
reldep6.c
reldep6mod0.c
reldep6mod1.c
reldep6mod2.c
reldep6mod3.c
reldep6mod4.c
reldep7.c
reldep7mod1.c
reldep7mod2.c
reldep8.c
reldep8mod1.c
reldep8mod2.c
reldep8mod3.c
reldep9.c
reldep9mod1.c
reldep9mod2.c
reldep9mod3.c
reldep.c
reldepmod1.c
reldepmod2.c
reldepmod3.c
reldepmod4.c
reldepmod5.c
reldepmod6.c
resolvfail.c
restest1.c
restest2.c
rtld-debugger-interface.txt
rtld-Rules Fix $(error) use in Makefile 2017-09-10 17:39:39 +02:00
rtld.c ld.so: Replace (&bootstrap_map) with BOOTSTRAP_MAP 2017-10-03 01:55:12 -07:00
setup-vdso.h
sln.c
sofini.c
soinit.c Narrowing the visibility of libc-internal.h even further. 2017-03-01 20:33:46 -05:00
sotruss-lib.c
sotruss.sh
sprof.c
static-stubs.c
testobj1_1.c
testobj1.c
testobj2.c
testobj3.c
testobj4.c
testobj5.c
testobj6.c PowerPC64 ELFv2 PPC64_OPT_LOCALENTRY 2017-06-14 10:47:25 +09:30
testobj.h
tls-macros.h
tlsdeschtab.h Mark lazy tlsdesc helper functions unused to avoid warnings 2017-11-03 14:40:28 +00:00
tst-_dl_addr_inside_object.c elf: Remove internal_function attribute 2017-08-31 16:59:37 +02:00
tst-addr1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-align2.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-align.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-alignmod2.c
tst-alignmod.c
tst-array1-static.c
tst-array1.c
tst-array1.exp
tst-array2.c
tst-array2.exp
tst-array2dep.c
tst-array3.c
tst-array4.c
tst-array4.exp
tst-array5-static.c
tst-array5-static.exp
tst-array5.c
tst-array5.exp
tst-array5dep.c
tst-audit1.c
tst-audit2.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-audit8.c
tst-audit9.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-audit11.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-audit11mod1.c
tst-audit11mod2.c
tst-audit11mod2.map
tst-audit12.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-audit12mod1.c
tst-audit12mod2.c
tst-audit12mod2.map
tst-audit12mod3.c
tst-auditmod1.c
tst-auditmod9a.c
tst-auditmod9b.c
tst-auditmod11.c
tst-auditmod12.c
tst-auxv.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-debug1.c Skip PT_DYNAMIC segment with p_filesz == 0 [BZ #22101] 2017-09-26 13:50:01 -07:00
tst-deep1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-deep1mod1.c
tst-deep1mod2.c
tst-deep1mod3.c
tst-dl-iter-static.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-dlmodcount.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-dlmopen1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-dlmopen1mod.c
tst-dlmopen2.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-dlmopen3.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-dlopen-aout.c Define TEST_FUNCTION_ARGV in elf/tst-dlopen-aout.c 2017-04-05 14:09:38 -07:00
tst-dlopenrpath.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-dlopenrpathmod.c
tst-dlsym-error.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-env-setuid-tunables.c Suppress internal declarations for most of the testsuite. 2017-05-11 19:27:59 -04:00
tst-env-setuid.c Ignore and remove LD_HWCAP_MASK for AT_SECURE programs (bug #21209) 2017-03-07 20:52:04 +05:30
tst-execstack-mod.c
tst-execstack-needed.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-execstack-prog.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-execstack.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-global1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-gnu2-tls1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-gnu2-tls1mod.c
tst-initorder2.c
tst-initorder2.exp
tst-initorder.c
tst-initorder.exp
tst-initordera1.c
tst-initordera2.c
tst-initordera3.c
tst-initordera4.c
tst-initorderb1.c
tst-initorderb2.c
tst-latepthread.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-latepthreadmod.c
tst-ldconfig-X.sh
tst-leaks1-static.c
tst-leaks1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-linkall-static.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-main1.c Add a test for main () in a shared object 2017-10-04 15:40:49 -07:00
tst-main1mod.c Add a test for main () in a shared object 2017-10-04 15:40:49 -07:00
tst-nodelete2.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-nodelete2mod.c
tst-nodelete-dlclose-dso.c
tst-nodelete-dlclose-plugin.c
tst-nodelete-dlclose.c
tst-nodelete-opened-lib.c
tst-nodelete-opened.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-nodelete-rtldmod.cc
tst-nodelete-uniquemod.cc
tst-nodelete-zmod.cc
tst-nodelete.cc Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-noload.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-null-argv-lib.c
tst-null-argv.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-order-a1.c
tst-order-a2.c
tst-order-a3.c
tst-order-a4.c
tst-order-b1.c
tst-order-b2.c
tst-order-main.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-pathopt.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-pathopt.sh
tst-pie1.c
tst-pie2.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-piemod1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-prelink.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-prelink.exp
tst-protected1a.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-protected1b.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-protected1mod.h
tst-protected1moda.c
tst-protected1modb.c
tst-ptrguard1-static.c
tst-ptrguard1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-relsort1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-relsort1mod1.c
tst-relsort1mod2.c
tst-rtld-load-self.sh
tst-stackguard1-static.c
tst-stackguard1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-thrlock.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls1-static-non-pie.c Add a test for non-PIE static executable 2017-09-30 01:39:32 -07:00
tst-tls1-static.c
tst-tls1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls2-static.c
tst-tls2.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls3.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls4.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls5.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls6.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls7.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls8.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls9-static.c
tst-tls9.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls10.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls10.h
tst-tls11.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls12.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls13.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls14.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls15.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls16.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls17.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls18.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls19.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls19mod1.c
tst-tls19mod2.c
tst-tls19mod3.c
tst-tls-dlinfo.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls-manydynamic.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tls-manydynamic.h
tst-tls-manydynamicmod.c
tst-tlsalign-extern-static.c
tst-tlsalign-extern.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tlsalign-lib.c
tst-tlsalign-static.c
tst-tlsalign-vars.c
tst-tlsalign.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-tlsmod1.c
tst-tlsmod2.c
tst-tlsmod3.c
tst-tlsmod4.c
tst-tlsmod5.c
tst-tlsmod6.c
tst-tlsmod7.c
tst-tlsmod8.c
tst-tlsmod9.c
tst-tlsmod10.c
tst-tlsmod11.c
tst-tlsmod12.c
tst-tlsmod13.c
tst-tlsmod13a.c
tst-tlsmod14a.c
tst-tlsmod14b.c
tst-tlsmod15a.c
tst-tlsmod15b.c
tst-tlsmod16a.c
tst-tlsmod16b.c
tst-tlsmod17a.c
tst-tlsmod17b.c
tst-tlsmod18a.c
tst-unique1.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-unique1mod1.c
tst-unique1mod2.c
tst-unique2.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
tst-unique2mod1.c
tst-unique2mod2.c
tst-unique3.cc
tst-unique3.h
tst-unique3lib2.cc
tst-unique3lib.cc
tst-unique4.cc
tst-unique4.h
tst-unique4lib.cc
unload2.c
unload2dep.c
unload2mod.c
unload3.c
unload3mod1.c
unload3mod2.c
unload3mod3.c
unload3mod4.c
unload4.c
unload4mod1.c
unload4mod2.c
unload4mod3.c
unload4mod4.c
unload5.c
unload6.c
unload6mod1.c
unload6mod2.c
unload6mod3.c
unload7.c
unload7mod1.c
unload7mod2.c
unload8.c
unload8mod1.c
unload8mod1x.c
unload8mod2.c
unload8mod3.c
unload.c
unloadmod.c
Versions ld.so: Introduce struct dl_exception 2017-08-10 16:54:57 +02:00
vismain.c Update elf tests to use the support test driver. 2017-04-05 10:34:58 -03:00
vismod1.c
vismod2.c
vismod3.c
vismod.h