From a87356db51791224ca525d248804a81d2e89d7c9 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Wed, 9 Jan 2019 22:14:11 +1100 Subject: libdl: Fix the support for constructors and desctructors. - Fix the handling of pending objects. - Add a constructor flags in objects to track then being called. --- cpukit/libdl/rtl-elf.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cpukit/libdl/rtl-elf.c') diff --git a/cpukit/libdl/rtl-elf.c b/cpukit/libdl/rtl-elf.c index caa37e6bab..63242acaae 100644 --- a/cpukit/libdl/rtl-elf.c +++ b/cpukit/libdl/rtl-elf.c @@ -993,6 +993,24 @@ rtems_rtl_elf_parse_sections (rtems_rtl_obj* obj, int fd, Elf_Ehdr* ehdr) flags = RTEMS_RTL_OBJ_SECT_STR; break; + case SHT_INIT_ARRAY: + /* + * Constructors are text and need to be loaded. + */ + flags = (RTEMS_RTL_OBJ_SECT_CTOR | + RTEMS_RTL_OBJ_SECT_TEXT | + RTEMS_RTL_OBJ_SECT_LOAD); + break; + + case SHT_FINI_ARRAY: + /* + * Destructors are text and need to be loaded. + */ + flags = (RTEMS_RTL_OBJ_SECT_DTOR | + RTEMS_RTL_OBJ_SECT_TEXT | + RTEMS_RTL_OBJ_SECT_LOAD); + break; + default: /* * See if there are architecture specific flags? @@ -1019,6 +1037,9 @@ rtems_rtl_elf_parse_sections (rtems_rtl_obj* obj, int fd, Elf_Ehdr* ehdr) if ((shdr.sh_flags & SHF_LINK_ORDER) != 0) flags |= RTEMS_RTL_OBJ_SECT_LINK; + /* + * Some architexctures support a named PROGBIT section for INIT/FINI. + */ len = RTEMS_RTL_ELF_STRING_MAX; if (!rtems_rtl_obj_cache_read (strings, fd, sectstroff + shdr.sh_name, -- cgit v1.2.3