Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By cal
#19444 Moin,

I am trying to reduce the size for linked firmware to have more room for application code
and file system.

I saw that symbols like __udivsi3 and __udivdi3 are used from libgcc.a and I would like
to replace them by a reference to the firmware routines:
Code: Select allld/eagle.rom.addr.v6.ld:PROVIDE ( __udivdi3 = 0x4000d310 );
ld/eagle.rom.addr.v6.ld:PROVIDE ( __udivsi3 = 0x4000e21c );


I can't get the linker to use them!
I know that PROVIDE has a lower priority than command line arguments and so I tried with an explicit
symbol in linker script without success.

Any idea how to make the linker use the ROM firmware symbol?
On another system we used small assembler stubs for this but the variant I can think of
would at least waste about 12 bytes per function for nothing.

Any idea?

Cal
User avatar
By pvvx
#19449 https://github.com/pvvx/esp8266web/tree/master/ld
https://github.com/pvvx/esp8266web/tree/master/lib new_libmc.bat new_libmgcc.bat libmc_list_files.txt libmgcc_list_files.txt
Optimized library: libmgcc.a libmc.a
Next step - use esp_microc: https://github.com/anakod/esp_microc

musl -> esp_microc: http://www.etalabs.net/compare_libcs.html
User avatar
By cal
#19453 Moin,

thanks, I saw them before.
If I didn't missed something you seem to just strip some objects from the libs.

Sure its possible to change the library.
I currenty try to avoid changing the library itself and stay on linker level.

A micro clib does not help in getting access to the rom symbols but thanks for reminding me of those.

Btw. I currently use a hacky way to let gnu ld ignore some symbols from libgcc using -Wl,--wrap and PROVIDE.

Your stripped down boot is cool. I thought about contacting you about coordinating some
reverse engeniering on the binary blobs of esp sdk.
Do you have some checking in place to see which parts of the binary libraries got changed
so one can concentrate on those only?
I typically did not translate back to c but stay on commented asm level but I found
it more effective to look at the wdt.c and think about converting some where useful.

BTW: Any reason you disabled -Os and use -O2 on your code?

Cal
User avatar
By pvvx
#19455
cal wrote:BTW: Any reason you disabled -Os and use -O2 on your code?
-Os = Big size :)
gcc curve compiler. GCC ESP8266 does not use a offset by reference to variable and creates a lot of downloadable constants in 'text' section. + No optimization (associations) of these constants... gcc curve compiler...