2015-09-25 08:56 AM
Hello All,
Hope you are doing well Clive. Seems like the forums have spam in them ? All those Chinese chars with ''university of xxyy'' stuff ? Anyway I've come back with another question. I have code that works well and is easy to use and interface with. I was wondering is there any way I can compile that code into a binary that people can simply link to and give the defines where my functions are ? Basically I want people to be able to use all the functionality of the code but only through the interfaces that I specify so they are not overwhelmed with the entire code library. Similar to an OS. I was thinking if I could just compile my code then the user could use their IDE to inject it into a certain location of the flash, then they could simply setup some pointers to where the functions now exist in flash and call them. Lets say my code ends up at 0x9000 and I have my init function at 0x9100 I could include a header file that does stuff likeint (*functionPtr)(int,int);
functionPtr = 0x9100;Then they could just call the functionPtr and call my code. I know this may make a lot more sense to you guys, but to me its new. Anyone know how I could do this sort of think using Keil ? I would only have a few functions Init()HandleCommand(command, value)AddCallBack(State, Callback) #code-library2015-09-25 09:11 AM
Well the linker can generate library (.A, .LIB) and object files (.O) that can be added to other projects.
I guess you're real issue would be stripping out all the extraneous symbols that you don't want anyone to see. I've written tools to sanitize .ELF object files before. You can define the internal routines as ''static'' and play with the debug symbol settings to reduce the noise there. You could conceivably create a binary blob, and generate a hex array you could #include, and provide a jump/vector table at the beginning so you don't have to keep changing the entry points. You'd also want the code to be address independent.