Skip to content

Commit

Permalink
ld.elf_so: Add stub library to access non-POSIX rtld api
Browse files Browse the repository at this point in the history
JIRA: RTOS-664
  • Loading branch information
badochov committed Aug 23, 2024
1 parent b759897 commit 4c7ff1f
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ld.elf_so/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ LANGUAGE_EXTENSIONS += %.S
include $(binary.mk)

LANGUAGE_EXTENSIONS := $(LANGUAGE_EXTENSIONS_OLD)


rtld: ld.elf_so librtld_stubs
rtld-install: ld.elf_so-install librtld_stubs-install
rtld-clean: ld.elf_so-clean librtld_stubs-clean
12 changes: 12 additions & 0 deletions ld.elf_so/stubs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Makefile for Phoenix-RTOS librtld_stubs
#
# Copyright 2024 Phoenix Systems
#

# Make library with stubs of non POSIX functions.
# This is required as this linker doesn't allow to add itself to NEEDED libs.
# To resolve a symbol from linker in dynamic binary a weak symbol is required.
NAME := librtld_stubs
LOCAL_SRCS := librtld_stubs.c
include $(shared-lib.mk)
62 changes: 62 additions & 0 deletions ld.elf_so/stubs/librtld_stubs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Phoenix-RTOS
*
* librtld_stubs
*
* Copyright 2024 Phoenix Systems
* Author: Hubert Badocha
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include <stdlib.h>

#include "../include/NetBSD/dlfcn.h"
#include "../include/NetBSD/link_elf.h"


void *___dlauxinfo(void)
{
abort();
}


int __dlctl(void *a, int b, void *c)
{
abort();
}


int __dlinfo(void *a, int b, void *c)
{
abort();
}


void *__dlvsym(void * restrict a, const char * restrict b, const char * restrict c)
{
abort();
}


void ____dl_cxa_refcount(void *a, ssize_t b)
{
abort();
}


int __dl_iterate_phdr(int (*a)(struct dl_phdr_info *, size_t, void *), void *b)
{
abort();
}


extern void *_dlauxinfo(void) __attribute__((__pure__, weak, alias("___dlauxinfo")));

extern int dlctl(void *, int, void *) __attribute__((weak, alias("__dlctl")));
extern int dlinfo(void *, int, void *) __attribute__((weak, alias("__dlinfo")));
extern void *dlvsym(void * restrict, const char * restrict, const char * restrict) __attribute__((weak, alias("__dlvsym")));
extern void __dl_cxa_refcount(void *, ssize_t) __attribute__((weak, alias("____dl_cxa_refcount")));
extern int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *) __attribute__((weak, alias("__dl_iterate_phdr")));

0 comments on commit 4c7ff1f

Please sign in to comment.