Question:
How to encrypt a library (.dlb) file and use It in another CCES Projects?
Answer:
To securely create and reuse a static library (.dlb) across projects in CCES, follow these steps:
I. Encrypt the Static Library:
1. Assume that your static library (original.dlb) has already been built in a CCES project.
2. Add the command like below, as example - to the post-build step of the project to encrypt the library using the elfar utility:
elfar -s -ve encypted.dlb original.dlb exclude_file.txt en
Where:
• -s - selects the encryption operation.
• -ve - switch will produce a table of global symbols and their encrypted form (Refer screenshot for reference.)
This table can be useful for debugging link errors
• encypted - specifies the name of the library (.dlb) file to be produced by the encryption process
• original - specifies the name of the archive (.dlb) file to be encrypted. This file is not altered by the encryption process, unless in-archive is the same as out-archive.
• exclude-file - specifies the name of a text file containing a list of symbols not to be encrypted. The symbols are listed one or more to a line,separated by white space.
• en - one or two letters that are used as the initial letters of encrypted symbols.
Note: Ensure that any symbols you intend to use in other projects are listed in exclude_file.txt to avoid encryption.
II. Link the Encrypted Library in Another Project:
1. To use the encrypted .dlb in a different CCES project, link this encrypted dlb file in main project navigate to project properties ->
C/C++ Build > Settings > Tool Settings > CrossCore SHARC Linker > General.
2. In the "Additional libraries and object files" field, add the path to encrypted.dlb.
3. Build the project and verify.
If encountered any linker errors (e.g., unresolved symbols), use the -ve option in elfar to inspect the encrypted symbol mappings and its corresponding names.
Refer the attached library project and the main project for reference.
• Library Project – where the encrypted .dlb is created.
• Main Project – where the encrypted .dlb is linked and used.