@@ -49,10 +49,6 @@ _dl_process_cet_property_note (struct link_map *l,
const ElfW(Addr) align)
{
#if CET_ENABLED
- /* Skip if we have seen a NT_GNU_PROPERTY_TYPE_0 note before. */
- if (l->l_cet != lc_unknown)
- return;
-
/* The NT_GNU_PROPERTY_TYPE_0 note must be aliged to 4 bytes in
32-bit objects and to 8 bytes in 64-bit objects. Skip notes
with incorrect alignment. */
@@ -152,33 +148,36 @@ _dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph,
int fd, struct filebuf *fbp)
{
# if CET_ENABLED
- const ElfW(Nhdr) *note;
- ElfW(Nhdr) *note_malloced = NULL;
- ElfW(Addr) size = ph->p_filesz;
-
- if (ph->p_offset + size <= (size_t) fbp->len)
- note = (const void *) (fbp->buf + ph->p_offset);
- else
+ if (l->l_cet == lc_unknown)
{
- if (size < __MAX_ALLOCA_CUTOFF)
- note = alloca (size);
+ const ElfW(Nhdr) *note;
+ ElfW(Nhdr) *note_malloced = NULL;
+ ElfW(Addr) size = ph->p_filesz;
+
+ if (ph->p_offset + size <= (size_t) fbp->len)
+ note = (const void *) (fbp->buf + ph->p_offset);
else
{
- note_malloced = malloc (size);
- note = note_malloced;
- }
- __lseek (fd, ph->p_offset, SEEK_SET);
- if (__read_nocancel (fd, (void *) note, size) != size)
- {
- if (note_malloced)
- free (note_malloced);
- return -1;
+ if (size < __MAX_ALLOCA_CUTOFF)
+ note = alloca (size);
+ else
+ {
+ note_malloced = malloc (size);
+ note = note_malloced;
+ }
+ __lseek (fd, ph->p_offset, SEEK_SET);
+ if (__read_nocancel (fd, (void *) note, size) != size)
+ {
+ if (note_malloced)
+ free (note_malloced);
+ return -1;
+ }
}
- }
- _dl_process_cet_property_note (l, note, size, ph->p_align);
- if (note_malloced)
- free (note_malloced);
+ _dl_process_cet_property_note (l, note, size, ph->p_align);
+ if (note_malloced)
+ free (note_malloced);
+ }
# endif
return 0;
}
@@ -187,8 +186,12 @@ _dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph,
static inline int __attribute__ ((unused))
_rtld_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph)
{
- const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
- _dl_process_cet_property_note (l, note, ph->p_memsz, ph->p_align);
+ /* Skip if we have seen a NT_GNU_PROPERTY_TYPE_0 note before. */
+ if (l->l_cet == lc_unknown)
+ {
+ const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
+ _dl_process_cet_property_note (l, note, ph->p_memsz, ph->p_align);
+ }
return 0;
}