From 803eac954ed7a3481c6af9b020d5d25419d3a19d Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Tue, 13 Nov 2018 17:26:17 +1100 Subject: libdl: Manage the allocation of common uninitialised variables. The use of separate text and data results in uninitialised variables being placed in the common section. There is no section in ELF for the common variables so the loader needs to create the section and allocate the variables in that section. This patch does that. The patch adds a second pass over the symbols. The issue can also be seen as a section 65522 error. Updates #3604 --- cpukit/include/rtems/rtl/rtl-obj.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'cpukit/include/rtems') diff --git a/cpukit/include/rtems/rtl/rtl-obj.h b/cpukit/include/rtems/rtl/rtl-obj.h index ff7b2a197d..be77a81c9d 100644 --- a/cpukit/include/rtems/rtl/rtl-obj.h +++ b/cpukit/include/rtems/rtl/rtl-obj.h @@ -293,6 +293,23 @@ static inline bool rtems_rtl_obj_text_inside (const rtems_rtl_obj* obj, (address < (obj->text_base + obj->text_size)); } +/** + * Align the size to the next alignment point. Assume the alignment is a + * positive integral power of 2 if not 0 or 1. If 0 or 1 then there is no + * alignment. + * + * @param offset Offset to align up from. + * @param alignment The alignment. + * @return size_t Aligned offset. + */ +static inline size_t rtems_rtl_obj_align (size_t offset, + uint32_t alignment) +{ + if ((alignment > 1) && ((offset & (alignment - 1)) != 0)) + offset = (offset + alignment) & ~(alignment - 1); + return offset; +} + /** * Allocate an object structure on the heap. * @@ -409,6 +426,22 @@ rtems_rtl_obj_sect* rtems_rtl_obj_find_section (const rtems_rtl_obj* obj, rtems_rtl_obj_sect* rtems_rtl_obj_find_section_by_index (const rtems_rtl_obj* obj, int index); +/** + * Find a section given a section's mask. The index is the section after which + * the mask is matched. An index of -1 starts the search from the beginning of + * the section list. You can find multiple matches for a mask by passing the + * index of the last section that matched the mask on a subsequent call. + * + * @param obj The object file's descriptor. + * @param index The section's index to start searching from, -1 for the start. + * @param mask The section's mask to match against the section's flags. + * @retval NULL The section was not found. + * @return rtems_rtl_obj_sect_t* The found section. + */ +rtems_rtl_obj_sect* rtems_rtl_obj_find_section_by_mask (const rtems_rtl_obj* obj, + int index, + uint32_t mask); + /** * The text section size. Only use once all the sections has been added. It * includes alignments between sections that are part of the object's text -- cgit v1.2.3