forked from Imagelibrary/rtems
libdl: Add small data support to the remaining PowerPC BSPs.
Updates #3687
This commit is contained in:
@@ -27,6 +27,15 @@ RamBase = bsp_ram_start;
|
||||
RamSize = bsp_ram_size;
|
||||
HeapSize = DEFINED(HeapSize) ? HeapSize : 0x0;
|
||||
|
||||
/*
|
||||
* The upper layer linker command file may optionally define the symbol
|
||||
* bsp_section_small_data_area_size. By default, the small data area is
|
||||
* defined by the .sdata and .sbss input sections. Define
|
||||
* bsp_section_small_data_area_size, if you want to make space available for
|
||||
* dynamically loaded libraries (libdl). Small memory targets which do not use
|
||||
* libdl, should not define this symbol.
|
||||
*/
|
||||
|
||||
MEMORY {
|
||||
UNEXPECTED_SECTIONS : ORIGIN = 0xffffffff, LENGTH = 0
|
||||
}
|
||||
@@ -233,6 +242,7 @@ SECTIONS {
|
||||
} > RAM
|
||||
|
||||
.sdata : {
|
||||
bsp_section_sdata_begin = .;
|
||||
PROVIDE (_SDA_BASE_ = 32768);
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
||||
|
||||
@@ -245,13 +255,14 @@ SECTIONS {
|
||||
* BSP: End of data section
|
||||
*/
|
||||
bsp_section_data_end = .;
|
||||
bsp_section_sdata_end = .;
|
||||
} > RAM
|
||||
|
||||
.sbss : {
|
||||
/*
|
||||
* BSP: Start of bss section
|
||||
*/
|
||||
bsp_section_bss_start = .;
|
||||
bsp_section_sbss_begin = .;
|
||||
|
||||
__bss_start = .;
|
||||
|
||||
@@ -260,11 +271,17 @@ SECTIONS {
|
||||
*(.dynsbss)
|
||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||
PROVIDE (__sbss_end = .); PROVIDE (___sbss_end = .);
|
||||
bsp_section_sbss_end = .;
|
||||
bsp_section_sdata_libdl_begin = .;
|
||||
. = DEFINED(bsp_section_small_data_area_size) ?
|
||||
bsp_section_sdata_begin + bsp_section_small_data_area_size : .;
|
||||
bsp_section_sdata_libdl_end = .;
|
||||
|
||||
. = ALIGN (bsp_section_align);
|
||||
} > RAM
|
||||
|
||||
.bss : {
|
||||
bsp_section_bss_start = .;
|
||||
*(COMMON)
|
||||
*(.dynbss)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
|
||||
@@ -24,6 +24,10 @@ MEMORY {
|
||||
/*FLASH : ORIGIN = 0xFFE00000, LENGTH = 16M*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Max sdata/bss.
|
||||
*/
|
||||
bsp_section_small_data_area_size = 65536;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
@@ -217,19 +221,27 @@ SECTIONS
|
||||
.sdata : {
|
||||
. = ALIGN (4);
|
||||
PROVIDE (__SDATA_START__ = .);
|
||||
bsp_section_sdata_begin = .;
|
||||
sdata.start = .;
|
||||
*(.sdata*)
|
||||
*(.gnu.linkonce.s.*)
|
||||
sdata.end = .;
|
||||
bsp_section_sdata_end = .;
|
||||
} > RAM
|
||||
|
||||
/* Zeroed small data addressed as offsets from r13 */
|
||||
.sbss : {
|
||||
. = ALIGN (4);
|
||||
PROVIDE(__SBSS_START__ = .);
|
||||
bsp_section_sbss_begin = .;
|
||||
sbss.start = .;
|
||||
*(.sbss .sbss.* *.gnu.linkonce.sb.*);
|
||||
sbss.end = .;
|
||||
bsp_section_sbss_end = .;
|
||||
bsp_section_sdata_libdl_begin = .;
|
||||
. = DEFINED(bsp_section_small_data_area_size) ?
|
||||
bsp_section_sdata_begin + bsp_section_small_data_area_size : .;
|
||||
bsp_section_sdata_libdl_end = .;
|
||||
} > RAM
|
||||
PROVIDE(__SBSS_END__ = .);
|
||||
|
||||
|
||||
@@ -229,18 +229,26 @@ SECTIONS
|
||||
PROVIDE (__FIXUP_END__ = .);
|
||||
|
||||
.sdata : {
|
||||
bsp_section_sdata_begin = .;
|
||||
PROVIDE (_SDA_BASE_ = 32768);
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
||||
bsp_section_sdata_end = .;
|
||||
} > ram
|
||||
|
||||
.sbss : {
|
||||
__bss_start = .;
|
||||
bsp_section_sbss_begin = .;
|
||||
|
||||
PROVIDE (__sbss_start = .); PROVIDE (___sbss_start = .);
|
||||
*(.scommon)
|
||||
*(.dynsbss)
|
||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||
PROVIDE (__sbss_end = .); PROVIDE (___sbss_end = .);
|
||||
bsp_section_sbss_end = .;
|
||||
bsp_section_sdata_libdl_begin = .;
|
||||
. = DEFINED(bsp_section_small_data_area_size) ?
|
||||
bsp_section_sdata_begin + bsp_section_small_data_area_size : .;
|
||||
bsp_section_sdata_libdl_end = .;
|
||||
} > ram
|
||||
|
||||
.sdata2 : {
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
|
||||
"elf32-powerpc")
|
||||
OUTPUT_ARCH(powerpc)
|
||||
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
MEMORY {
|
||||
VECTORS : ORIGIN = 0x0 , LENGTH = 0x3000
|
||||
CODE : ORIGIN = 0x3000 , LENGTH = 32M - 0x3000
|
||||
}
|
||||
|
||||
/*
|
||||
* The upper layer linker command file may optionally define the symbol
|
||||
* bsp_section_small_data_area_size. By default, the small data area is
|
||||
* defined by the .sdata and .sbss input sections. Define
|
||||
* bsp_section_small_data_area_size, if you want to make space available for
|
||||
* dynamically loaded libraries (libdl). Small memory targets which do not use
|
||||
* libdl, should not define this symbol.
|
||||
*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.entry_point_section :
|
||||
@@ -215,11 +226,17 @@ SECTIONS
|
||||
/* We want the small data sections together, so single-instruction offsets
|
||||
can access them all, and initialized data all before uninitialized, so
|
||||
we can shorten the on-disk segment size. */
|
||||
.sdata : { PROVIDE (_SDA_BASE_ = 32768); *(.sdata*) *(.gnu.linkonce.s.*) } >CODE
|
||||
.sdata : {
|
||||
bsp_section_sdata_begin = .;
|
||||
PROVIDE (_SDA_BASE_ = 32768);
|
||||
*(.sdata*) *(.gnu.linkonce.s.*)
|
||||
bsp_section_sdata_end = .;
|
||||
} > CODE
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
.sbss :
|
||||
{
|
||||
bsp_section_sbss_begin = .;
|
||||
PROVIDE (__sbss_start = .);
|
||||
*(.dynsbss)
|
||||
*(.sbss* .gnu.linkonce.sb.*)
|
||||
@@ -230,6 +247,11 @@ SECTIONS
|
||||
. += 1;
|
||||
PROVIDE (__SBSS_END__ = .);
|
||||
PROVIDE (__sbss_end = .);
|
||||
bsp_section_sbss_end = .;
|
||||
bsp_section_sdata_libdl_begin = .;
|
||||
. = DEFINED(bsp_section_small_data_area_size) ?
|
||||
bsp_section_sdata_begin + bsp_section_small_data_area_size : .;
|
||||
bsp_section_sdata_libdl_end = .;
|
||||
} > CODE
|
||||
.plt : { *(.plt) } > CODE
|
||||
.bss :
|
||||
|
||||
@@ -204,9 +204,11 @@ SECTIONS
|
||||
* offsets can access them all.
|
||||
*/
|
||||
PROVIDE (__SDATA2_START__ = .);
|
||||
bsp_section_sdata_begin = .;
|
||||
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
|
||||
*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
|
||||
PROVIDE (__SDATA2_END__ = .);
|
||||
bsp_section_sdata_end = .;
|
||||
|
||||
data.end = .;
|
||||
}
|
||||
@@ -216,10 +218,16 @@ SECTIONS
|
||||
.sbss :
|
||||
{
|
||||
PROVIDE (__sbss_start = .); PROVIDE (___sbss_start = .);
|
||||
bsp_section_sbss_begin = .;
|
||||
*(.dynsbss)
|
||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||
*(.scommon)
|
||||
PROVIDE (__sbss_end = .); PROVIDE (___sbss_end = .);
|
||||
bsp_section_sbss_end = .;
|
||||
bsp_section_sdata_libdl_begin = .;
|
||||
. = DEFINED(bsp_section_small_data_area_size) ?
|
||||
bsp_section_sdata_begin + bsp_section_small_data_area_size : .;
|
||||
bsp_section_sdata_libdl_end = .;
|
||||
}
|
||||
.bss :
|
||||
{
|
||||
|
||||
@@ -209,13 +209,18 @@ SECTIONS
|
||||
* we can shorten the on-disk segment size.
|
||||
*/
|
||||
/* Initialised small data addressed as offsets from r13 */
|
||||
.sdata : { PROVIDE (_SDA_BASE_ = 32768); *(.sdata* .gnu.linkonce.s.*) } > RAM
|
||||
.sdata : {
|
||||
bsp_section_sdata_begin = .;
|
||||
PROVIDE (_SDA_BASE_ = 32768); *(.sdata* .gnu.linkonce.s.*);
|
||||
bsp_section_sdata_end = .;
|
||||
} > RAM
|
||||
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
|
||||
/* Zeroed small data addressed as offsets from r13 */
|
||||
.sbss : { PROVIDE (__sbss_start = .);
|
||||
bsp_section_sbss_begin = .;
|
||||
*(.dynsbss)
|
||||
*(.sbss*)
|
||||
*(.gnu.linkonce.sb.*)
|
||||
@@ -228,6 +233,11 @@ SECTIONS
|
||||
|
||||
PROVIDE (__SBSS_END__ = .);
|
||||
PROVIDE (__sbss_end = .);
|
||||
bsp_section_sbss_end = .;
|
||||
bsp_section_sdata_libdl_begin = .;
|
||||
. = DEFINED(bsp_section_small_data_area_size) ?
|
||||
bsp_section_sdata_begin + bsp_section_small_data_area_size : .;
|
||||
bsp_section_sdata_libdl_end = .;
|
||||
} > RAM
|
||||
|
||||
.plt : { *(.plt) } > RAM
|
||||
|
||||
@@ -209,13 +209,18 @@ SECTIONS
|
||||
* we can shorten the on-disk segment size.
|
||||
*/
|
||||
/* Initialised small data addressed as offsets from r13 */
|
||||
.sdata : { PROVIDE (_SDA_BASE_ = 32768); *(.sdata* .gnu.linkonce.s.*) } > RAM
|
||||
.sdata : {
|
||||
bsp_section_sdata_begin = .;
|
||||
PROVIDE (_SDA_BASE_ = 32768); *(.sdata* .gnu.linkonce.s.*);
|
||||
bsp_section_sdata_end = .;
|
||||
} > RAM
|
||||
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
|
||||
/* Zeroed small data addressed as offsets from r13 */
|
||||
.sbss : { PROVIDE (__sbss_start = .);
|
||||
bsp_section_sbss_begin = .;
|
||||
*(.dynsbss)
|
||||
*(.sbss*)
|
||||
*(.gnu.linkonce.sb.*)
|
||||
@@ -228,6 +233,11 @@ SECTIONS
|
||||
|
||||
PROVIDE (__SBSS_END__ = .);
|
||||
PROVIDE (__sbss_end = .);
|
||||
bsp_section_sbss_end = .;
|
||||
bsp_section_sdata_libdl_begin = .;
|
||||
. = DEFINED(bsp_section_small_data_area_size) ?
|
||||
bsp_section_sdata_begin + bsp_section_small_data_area_size : .;
|
||||
bsp_section_sdata_libdl_end = .;
|
||||
} > RAM
|
||||
|
||||
.plt : { *(.plt) } > RAM
|
||||
|
||||
@@ -50,11 +50,16 @@ get_sda_base (void)
|
||||
static void*
|
||||
get_sdata_start (void)
|
||||
{
|
||||
#if _ARCH_PPC64
|
||||
return NULL;
|
||||
#else
|
||||
Elf_Addr addr;
|
||||
GET_ADDR(__SDATA_START__, addr);
|
||||
return (void*) addr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !_ARCH_PPC64
|
||||
static size_t
|
||||
get_sdata_sbss_size (void)
|
||||
{
|
||||
@@ -74,6 +79,7 @@ get_sdata_libdl_size (void)
|
||||
GET_ADDR(bsp_section_sdata_libdl_end, end);
|
||||
return end - begin;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t
|
||||
rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
|
||||
@@ -89,6 +95,7 @@ rtems_rtl_elf_arch_parse_section (const rtems_rtl_obj* obj,
|
||||
const Elf_Shdr* shdr,
|
||||
const uint32_t flags)
|
||||
{
|
||||
#if !_ARCH_PPC64
|
||||
struct {
|
||||
const char* label;
|
||||
size_t len;
|
||||
@@ -104,6 +111,7 @@ rtems_rtl_elf_arch_parse_section (const rtems_rtl_obj* obj,
|
||||
if (strncmp (name, prefix[p].label, prefix[p].len) == 0)
|
||||
return flags | RTEMS_RTL_OBJ_SECT_ARCH_ALLOC;
|
||||
}
|
||||
#endif
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -111,6 +119,10 @@ bool
|
||||
rtems_rtl_elf_arch_section_alloc (const rtems_rtl_obj* obj,
|
||||
rtems_rtl_obj_sect* sect)
|
||||
{
|
||||
#if _ARCH_PPC64
|
||||
rtems_rtl_set_error (ENOMEM, ".sdata no supported by ABI");
|
||||
return false;
|
||||
#else
|
||||
if (rtems_rtl_trace (RTEMS_RTL_TRACE_DETAIL))
|
||||
printf ("rtl: section: arch: alloc: name=%s size=%zu flags=%08" PRIx32 \
|
||||
" order=%i link=%d info=%d\n",
|
||||
@@ -138,16 +150,19 @@ rtems_rtl_elf_arch_section_alloc (const rtems_rtl_obj* obj,
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
rtems_rtl_elf_arch_section_free (const rtems_rtl_obj* obj,
|
||||
rtems_rtl_obj_sect* sect)
|
||||
{
|
||||
#if !_ARCH_PPC64
|
||||
if (rtems_rtl_trace (RTEMS_RTL_TRACE_DETAIL))
|
||||
printf ("rtl: section: arch: free: name=%s size=%zu\n", sect->name, sect->size);
|
||||
if (sdata != NULL)
|
||||
rtems_rtl_bit_alloc_bfree (sdata, sect->base, sect->size);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user