Author Topic: armlibgen usage with emd file  (Read 316 times)

Offline cuevavirus

  • Hot Pockets
  • Useful Idiot
  • *****
  • Posts: 129
    • View Profile
armlibgen usage with emd file
« on: January 09, 2021, 04:46:39 PM »
armlibgen is an undocumented program in the official sdk that produces stub archives and assembly for module and library entry (also called module and library info). armlibgen accepts as input an elf containing input data in an unknown format, or a plaintext emd file. An emd file contains one or more directives, where a directive is a line containing one or more keyword value pairs. The valid directives for version 1.20.4 are

Code: [Select]
emd: <integer>
moduleinfo_output_format: <scelibent_table|emd|sn_linker_cmd>
Library: <symbol> attr: <integer|auto_export|weak_export|nolink_export|plugin_link|loose_import|syscall_export>
Library: <symbol> version: <integer>
Library: <symbol> stubfile: <string>
Library: <symbol> StubFile: <string>
Library: <symbol> nidsuffix: <string>
Library: <symbol> libnamenid: <integer>
Library: <symbol> function: <symbol> localname: <symbol|string> nidname: <symbol|string> openlevel: <integer> prototype: <string> nidvalue: <integer> bind: <global|weak|not_local>
Library: <symbol> variable: <symbol> localname: <symbol|string> nidname: <symbol|string> openlevel: <integer> prototype: <string> nidvalue: <integer> bind: <global|weak|not_local>
Library: <symbol> importer_long_data: <symbol|integer> label: <symbol> section: <string> flag: <string>
StubFile: <string> Library: <symbol>
Module: <symbol> major_version: <integer> minor_version: <integer>
module_attr: <integer|none|cant_stop|exclusive_load|exclusive_start|can_restart|can_relocate|cant_share>
module_function: <symbol> localname: <symbol> bind: <global|weak|not_local>
module_variable: <symbol> localname: <symbol> bind: <global|weak|not_local>
module_reserve_size: <symbol> size: <integer>
sceModuleInfo_type: <integer>
exporter_long_data: <symbol|integer> label: <symbol> section: <string> flag: <string>

The valid keywords are

Code: [Select]
Library
Module
OpenLink_space
StubFile
attr
bind
class
define
demangle
emd
exporter_long_data
filter
flag
function
importer_long_data
label
libnamenid
localname
major_version
minor_version
module_attr
module_function
module_reserve_size
module_variable
moduleinfo_output_format
name
namespace
nidname
nidsuffix
nidvalue
openlevel
prototype
sceModuleInfo_type
section
size
stubfile
type
variable
version
visibility

Not all keywords are used. Some keyword value pairs after the first one in a directive are optional.

Offline OsirisX

  • End User
  • *
  • Posts: 1
    • View Profile
Re: armlibgen usage with emd file
« Reply #1 on: February 09, 2021, 12:18:51 AM »
I've created a small script to generate emd files from a given YAML formatted library list.
https://gist.github.com/OsirizX/1f54a3f32bb343f96b715d25257cc352

For example you can pass in db.yml and it will generate emd files for each module definition.
Code: [Select]
python vita-emd-gen.py db.yml
armlibgen can then be used to create the stub libs for which you can link with the official sdk.
Code: [Select]
armlibgen libSceShaccCg.emd -s