#3685 closed defect (fixed)

Add large memory support to libdl

Reported by: Chris Johns Owned by: Chris Johns
Priority: normal Milestone: 5.1
Component: lib/dl Version: 5
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

Add large memory support to libdl. Some architectures use small relative offsets with smaller instructions for performance reasons. Object files loaded at addresses that are outside the relative range require trampoline calls that bridge the instruction in the object to the target symbol. The mechanism used depends on the archives.

Libdl requires generic support to parse the relocation record before the object file allocation to provide the memory to hold the trampoline calls.

The ARM and PowerPC architectures require trampolines. This is called veneers on ARM.

Change History (9)

comment:1 Changed on 02/08/19 at 23:08:11 by Chris Johns <chrisj@…>

In b08278e/rtems:

powerpc/psim: Increase the psim memory to 256M

This allows test dl09 to run and test PowePC backend trampoline support.

Updates #3685

comment:2 Changed on 02/08/19 at 23:08:35 by Chris Johns <chrisj@…>

In d8c70ba6/rtems:

libdl: Add support for trampolines

  • Trampolines or fixups for veneers provide long jump support for instruciton sets that implement short relative address branches. The linker provides trampolines when creating a static image. This patch adds trampoline support to libdl and the ARM architecture.
  • The dl09 test requires enough memory so modules are outside the relative branch instruction ranges for the architecture.

Updates #3685

comment:3 Changed on 02/08/19 at 23:08:38 by Chris Johns <chrisj@…>

In 194eb403/rtems:

libdl: Add support for large memory programs

  • Add trampolines to support relocs that are out of range on support architectures.
  • Support not loading separate text/data sections in an object file if the symbol provided in the section is a duplicate. A base image may have pulled in part of an object and another part needs to be dynamically loaded.
  • Refactor the unresolved handling to scale to hundreds of unresolved symbols when loading large number of files.

Updates #3685

comment:4 Changed on 02/08/19 at 23:08:42 by Chris Johns <chrisj@…>

In 6c9f017/rtems:

libdl: Add powerpc large memory and small data support.

  • Add support for architecure sections that can be handled by the architecture back end.
  • Add trampoline/fixup support for PowerPC. This means the PowerPC now supports large memory loading of applications.
  • Add a bit allocator to manage small block based regions of memory.
  • Add small data (sdata/sbss) support for the PowerPC. The support makes the linker allocated small data region of memory a global resource available to libdl loaded object files.

Updates #3687
Updates #3685

comment:5 Changed on 02/19/19 at 22:09:47 by Chris Johns <chrisj@…>

In 22afb034/rtems:

libdl/alloc: Add a locking interface to the allocator.

  • Allow an allocator to lock the allocations. This is needed to lock the heap allocator so the text and trampoline table are as close together as possible to allow for the largest possible object file size.
  • Update the default heap allocator to lock the heap allocator.
  • Update ELF loading to lock the allocator.

Updates #3685

comment:6 Changed on 12/13/19 at 08:33:02 by Sebastian Huber

b08278e/rtems leads to the following run-time error on PSIM:

BATs must not overlap; area 0x08000000..0x09000000 hits DBAT 0
BATs must not overlap; area 0x0c000000..0x0d000000 hits DBAT 0

The RAM overlaps with the PCI area:

  /*
   * Setup BATs and enable MMU
   */
  /* Memory */
  setdbat(0, 0x0<<28, 0x0<<28, 1<<28, _PAGE_RW);
  setibat(0, 0x0<<28, 0x0<<28, 1<<28,        0);
  /* PCI    */
  setdbat(1, 0x8<<24, 0x8<<24, 1<<24,  IO_PAGE);
  setdbat(2, 0xc<<24, 0xc<<24, 1<<24,  IO_PAGE);

comment:7 Changed on 12/13/19 at 08:41:49 by Sebastian Huber

Increasing the RAM size to 256MiB (0x10000000) on PSIM breaks also the shared memory support:

typedef struct {
  /* 0x0c000000 - 0x0c007FFF - AMD 29F040 */
  volatile uint8_t Flash[ 512 * 1024 ];

  /* 0x0c080000 - 0x0c0FFFFF - NVRAM/NVRAM */
  volatile uint8_t nvram[ 512 * 1024 ];

  /* 0x0c100000 - 0x0c100007 - NVRAM/RTC */
  psim_rtc_t RTC;

  /* 0x0c100008 - 0x0c10000F - NVRAM/RTC */
  uint8_t gap1[8];

  /* 0x0c100010 - 0x0c10001b - System V IPC Semaphore */
  psim_sysv_sem_t Semaphore;

  /* 0x0c10001c - 0x0c10001f - NVRAM/RTC */
  uint8_t gap2[4];

  /* 0x0c100020 - 0x0c10005F - Ethernet */
  volatile uint8_t Ethtap[ 64 ];

  /* 0x0c100060 - 0x0c10FFFF - NVRAM/RTC */
  uint8_t gap3[65440];

  /* 0x0c110000 - 0x0c12FFFF - System V IPC Shared Memory */
  uint8_t SharedMemory[ 128 * 1024 ];

  /* 0x0c130000 - 0x0c170000 - OpenPIC IRQ Controller */
  volatile uint8_t OpenPIC[ 256 * 1024 ];

} psim_registers_t;

I suggest to revert this change.

comment:8 Changed on 12/17/19 at 20:18:36 by Chris Johns

Resolution: fixed
Status: assignedclosed

The large memory support in libdl task has finished. The psim issue should be moved to another ticket and the solution is to change the address map of the devices as suggested by Joel on the devel@ list.

comment:9 Changed on 01/02/20 at 11:54:11 by Sebastian Huber

See #3849.

Note: See TracTickets for help on using tickets.