Create single-file executable and embed static files, for legacy C/Linux program -


i have legacy linux application written c relies upon static external files on filesystem. i'd bundle of them single executable, single-file executable doesn't rely upon in filesystem. there way this, without having make lots of changes existing code?

i can link program statically avoid dependencies on dynamic libraries, application relies upon other static resources (other read-only files on filesystem), i'd embed application. know how embed external file final executable using objcopy (e.g., described here or here), need arrange program use embedded blob instead of trying open file on filesystem. i've seen ways access these elf sections @ runtime (e.g., using linker symbol names or elfdataembed, described here , here), require me change every place in program accesses 1 of these external files instead refer embedded resource. sounds tedious , error-prone.

to reduce workload , reduce bugs, i'd prefer minimize amount of changes needed application's code. how can this, minimizing changes application? i'm thinking maybe wraps open() detect attempts open 1 of external files , redirecting them read blob embedded in executable, instance, though i'm not sure of details (e.g., how open() wrapper can create fake fd; whether i'll need wrap of other filesystem functions well) or pitfalls might be.

how can achieve this? or, there existing tool should know about, avoid re-inventing wheel?


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -