How does PlatformIO generate. map files?

Generating .map files is done by the compiler, GCC. You configure PlatformIO to tell GCC to do that via build_flags. See Generate a .map file - #8 by Krishna_Chaitanya