How to create a “shared library” intended to be statically resident at a fixed memory location

I am looking for a proper way to create firmware components for a following architecture without inventing the wheel.
Consider that the system has multiple firmware executables that can be either loaded dynamically, or execute in order by passing the control to each other. And there is a common functionality that is statically loaded into a known memory address and is callable by each of the executable firmware components:

|-------------------|
|      Executable 1 |
|-------------------|
|        ...        |
|-------------------|
|      Executable 2 |
|-------------------|
|        ...        |
|-------------------| <--- fixed address
|  Shared "library" |
|-------------------|

I’d like to be able to create the executables by linking their code with some artifact produced by the build process of the “library”, that is something like:

ld <some options and input objects> --just-symbols=library.syms  executable.elf

(both the library artifact and the executable will be flattened into a raw binary later, but this step is implied and isn’t important for the question sake).

Now, the question is how to actually build this library knowing the final location it would be stored at? Traditional static libraries are usually linked with the executable and are placed according to it’s linker script. One way I saw, is to actually produce another (elf) executable with a dummy main function and a specific linker script and use it as the “library” in the question, but it looks somewhat hack-ish way to me. In addition I am not sure it is safe and no functions that are expected to be exported are optimized out.

** Assuming GNU cross toolchain and whatever binutils in the disposal

8

This is done by “linker script”. https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html

As a very primitive example, you can do something like this:

SECTIONS {
  SecA 0x10000 : {
    foo.o (.text)
    bar.o (.text)
  }
  SecB : { * (.text) }
  .data : { *(.data) }
}

This would put all functions from object file foo.o at the specified absolute address. Once object foo.o is done, functions from the bar.o will be the second one.
Functions, from all other objects, with no regard to sorting object files would be after.
Finally you would have a separate section for global variables.

Please note, you cannot specify locations of functions. If you have two or more functions in an object – they would be put into final output as one batch. But you can go with a one file = one function approach. At least for functions which would require absolute placement.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật