Recent

Author Topic: [CLOSED] Linker map file  (Read 2835 times)

julkas

  • Guest
[CLOSED] Linker map file
« on: January 04, 2020, 02:35:14 pm »
On Windows -Xm generates linker map file -
Code: Text  [Select][+][-]
  1. Used linker script
  2.  
  3. ...
  4. READOBJECT C:\OLD_DISK\C_DISK\laz\fpc\3.0.4\units\i386-win32\rtl\system.o
  5. READOBJECT C:\OLD_DISK\C_DISK\laz\fpc\3.0.4\units\i386-win32\rtl\heaptrc.o
  6. READOBJECT C:\OLD_DISK\C_DISK\laz\fpc\3.0.4\units\i386-win32\rtl\lnfodwrf.o
  7. READOBJECT C:\OLD_DISK\C_DISK\laz\fpc\3.0.4\units\i386-win32\rtl\exeinfo.o
  8. READOBJECT C:\OLD_DISK\C_DISK\laz\fpc\3.0.4\units\i386-win32\rtl\strings.o
  9. READOBJECT C:\OLD_DISK\C_DISK\laz\fpc\3.0.4\units\i386-win32\rtl\windows.o
  10. READOBJECT C:\OLD_DISK\C_DISK\laz\fpc\3.0.4\units\i386-win32\rtl\objpas.o
  11. READOBJECT C:\OLD_DISK\C_DISK\laz\fpc\3.0.4\units\i386-win32\rtl\fpintres.o
  12.  

What does -Xm do for embedded ?





« Last Edit: January 06, 2020, 12:33:00 pm by julkas »

julkas

  • Guest
Re: Linker map file
« Reply #1 on: January 05, 2020, 02:39:04 pm »
How generate linker map file for embedded target ?
Thanks.

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Linker map file
« Reply #2 on: January 05, 2020, 02:48:22 pm »
Which embedded target? Please give more info so I or others might fix this problem in the FPC trunk.
EDIT : Ah, AVR. I don't have the utilities for AVR target, but does the AVR cross linker support generation of the map file?
This bugreport of mine can be use as an inspiration : https://bugs.freepascal.org/view.php?id=33982
« Last Edit: January 05, 2020, 02:52:32 pm by Cyrax »

julkas

  • Guest
Re: Linker map file
« Reply #3 on: January 05, 2020, 03:08:09 pm »
Which embedded target? Please give more info so I or others might fix this problem in the FPC trunk.
EDIT : Ah, AVR. I don't have the utilities for AVR target, but does the AVR cross linker support generation of the map file?
This bugreport of mine can be use as an inspiration : https://bugs.freepascal.org/view.php?id=33982

See option -Xm
Code: Text  [Select][+][-]
  1. $ ppcrossavr.exe
  2. Free Pascal Compiler version 3.3.1 [2020/01/01] for avr
  3. Copyright (c) 1993-2019 by Florian Klaempfl and others
  4. C:\OLD_DISK\C_DISK\fpc-avr\bin\i386-win32\ppcrossavr.exe [options] <inputfile> [options]
  5.  Put + after a boolean switch option to enable it, - to disable it.
  6.   @<x>   Read compiler options from <x> in addition to the default fpc.cfg
  7.   -a     The compiler does not delete the generated assembler file
  8.       -a5        Don't generate Big Obj COFF files for GNU Binutils older than 2.25 (Windows, NativeNT)
  9.       -al        List sourcecode lines in assembler file
  10.       -an        List node info in assembler file (-dEXTDEBUG compiler)
  11.       -ao        Add an extra option to external assembler call (ignored for internal)
  12.       -ar        List register allocation/release info in assembler file
  13.       -at        List temp allocation/release info in assembler file
  14.   -A<x>  Output format:
  15.       -Adefault  Use default assembler
  16.   -b     Generate browser info
  17.       -bl        Generate local symbol info
  18.   -B     Build all modules
  19.   -C<x>  Code generation options:
  20.       -C3        Turn on ieee error checking for constants
  21. *** press enter ***
  22.  
  23.       -Ca<x>     Select ABI; see fpc -i or fpc -ia for possible values
  24.       -Cb        Generate code for a big-endian variant of the target architecture
  25.       -Cc<x>     Set default calling convention to <x>
  26.       -CD        Create also dynamic library (not supported)
  27.       -Ce        Compilation with emulated floating point opcodes
  28.       -CE        Generate FPU code which can raise exceptions
  29.       -Cf<x>     Select fpu instruction set to use; see fpc -i or fpc -if for possible values
  30.       -CF<x>     Minimal floating point constant precision (default, 32, 64)
  31.       -Cg        Generate PIC code
  32.       -Ch<n>[,m] <n> bytes min heap size (between 1023 and 67107840) and optionally [m] max heap size
  33.       -Ci        IO-checking
  34.       -Cn        Omit linking stage
  35.       -Co        Check overflow of integer operations
  36.       -CO        Check for possible overflow of integer operations
  37.       -Cp<x>     Select instruction set; see fpc -i or fpc -ic for possible values
  38.       -CP<x>=<y>  packing settings
  39.          -CPPACKSET=<y>  <y> set allocation: 0, 1 or DEFAULT or NORMAL, 2, 4 and 8
  40. *** press enter ***
  41.  
  42.          -CPPACKENUM=<y>  <y> enum packing: 0, 1, 2 and 4 or DEFAULT or NORMAL
  43.          -CPPACKRECORD=<y>  <y> record packing: 0 or DEFAULT or NORMAL, 1, 2, 4, 8, 16 and 32
  44.       -Cr        Range checking
  45.       -CR        Verify object method call validity
  46.       -Cs<n>     Set stack checking size to <n>
  47.       -Ct        Stack checking (for testing only, see manual)
  48.       -CX        Create also smartlinked library
  49.   -d<x>  Defines the symbol <x>
  50.   -D     Generate a DEF file
  51.       -Dd<x>     Set description to <x>
  52.       -Dv<x>     Set DLL version to <x>
  53.   -e<x>  Set path to executable
  54.   -E     Same as -Cn
  55.   -fPIC  Same as -Cg
  56.   -F<x>  Set file names and paths:
  57.       -Fa<x>[,y] (for a program) load units <x> and [y] before uses is parsed
  58.       -Fc<x>     Set input codepage to <x>
  59.       -FC<x>     Set RC compiler binary name to <x>
  60.       -Fd        Disable the compiler's internal directory cache
  61.       -FD<x>     Set the directory where to search for compiler utilities
  62.       -Fe<x>     Redirect error output to <x>
  63. *** press enter ***
  64.  
  65.       -Ff<x>     Add <x> to framework path (Darwin only)
  66.       -FE<x>     Set exe/unit output path to <x>
  67.       -Fi<x>     Add <x> to include path
  68.       -Fl<x>     Add <x> to library path
  69.       -FL<x>     Use <x> as dynamic linker
  70.       -Fm<x>     Load unicode conversion table from <x>.txt in the compiler dir
  71.       -FM<x>     Set the directory where to search for unicode binary files
  72.       -FN<x>     Add <x> to list of default unit scopes (namespaces)
  73.       -Fo<x>     Add <x> to object path
  74.       -Fr<x>     Load error message file <x>
  75.       -FR<x>     Set resource (.res) linker to <x>
  76.       -Fu<x>     Add <x> to unit path
  77.       -FU<x>     Set unit output path to <x>, overrides -FE
  78.       -FW<x>     Store generated whole-program optimization feedback in <x>
  79.       -Fw<x>     Load previously stored whole-program optimization feedback from <x>
  80.   -g     Generate debug information (default format for target)
  81.       -gc        Generate checks for pointers (experimental, only available on some targets, might generate false positive)
  82.       -gh        Use heaptrace unit (for memory leak/corruption debugging)
  83.       -gl        Use line info unit (show more info with backtraces)
  84.       -gm        Generate Microsoft CodeView debug information (experimental)
  85. *** press enter ***
  86.  
  87.       -go<x>     Set debug information options
  88.          -godwarfsets  Enable DWARF 'set' type debug information (breaks gdb < 6.5)
  89.          -gostabsabsincludes  Store absolute/full include file paths in Stabs
  90.          -godwarfmethodclassprefix  Prefix method names in DWARF with class name
  91.          -godwarfcpp  Simulate C++ debug information in DWARF
  92.          -godwarfomflinnum  Generate line number information in OMF LINNUM records in MS LINK format in addition to the DWARF debug information (Open Watcom Debugger/Linker compatibility)
  93.       -gp        Preserve case in stabs symbol names
  94.       -gs        Generate Stabs debug information
  95.       -gt        Trash local variables (to detect uninitialized uses; multiple 't' changes the trashing value)
  96.       -gv        Generates programs traceable with Valgrind
  97.       -gw        Generate DWARFv2 debug information (same as -gw2)
  98.       -gw2       Generate DWARFv2 debug information
  99.       -gw3       Generate DWARFv3 debug information
  100.       -gw4       Generate DWARFv4 debug information (experimental)
  101.   -i     Information
  102.       -iD        Return compiler date
  103.       -iSO       Return compiler OS
  104. *** press enter ***
  105.  
  106.       -iSP       Return compiler host processor
  107.       -iTO       Return target OS
  108.       -iTP       Return target processor
  109.       -iV        Return short compiler version
  110.       -iW        Return full compiler version
  111.       -ia        Return list of supported ABI targets
  112.       -ic        Return list of supported CPU instruction sets
  113.       -if        Return list of supported FPU instruction sets
  114.       -ii        Return list of supported inline assembler modes
  115.       -io        Return list of supported optimizations
  116.       -ir        Return list of recognized compiler and RTL features
  117.       -it        Return list of supported targets
  118.       -iu        Return list of supported microcontroller types
  119.       -iw        Return list of supported whole program optimizations
  120.   -I<x>  Add <x> to include path
  121.   -k<x>  Pass <x> to the linker
  122.   -l     Write logo
  123.   -M<x>  Set language mode to <x>
  124.       -Mfpc      Free Pascal dialect (default)
  125.       -Mobjfpc   FPC mode with Object Pascal support
  126.       -Mdelphi   Delphi 7 compatibility mode
  127.       -Mtp       TP/BP 7.0 compatibility mode
  128. *** press enter ***
  129.  
  130.       -Mmacpas   Macintosh Pascal dialects compatibility mode
  131.       -Miso      ISO 7185 mode
  132.       -Mextendedpascal ISO 10206 mode
  133.       -Mdelphiunicode Delphi 2009 and later compatibility mode
  134.   -n     Do not read the default config files
  135.   -o<x>  Change the name of the executable produced to <x>
  136.   -O<x>  Optimizations:
  137.       -O-        Disable optimizations
  138.       -O1        Level 1 optimizations (quick and debugger friendly)
  139.       -O2        Level 2 optimizations (-O1 + quick optimizations)
  140.       -O3        Level 3 optimizations (-O2 + slow optimizations)
  141.       -O4        Level 4 optimizations (-O3 + optimizations which might have unexpected side effects)
  142.       -Oa<x>=<y> Set alignment
  143.       -Oo[NO]<x> Enable or disable optimizations; see fpc -i or fpc -io for possible values
  144.       -Op<x>     Set target cpu for optimizing; see fpc -i or fpc -ic for possible values
  145.       -OW<x>     Generate whole-program optimization feedback for optimization <x>; see fpc -i or fpc -iw for possible values
  146.       -Ow<x>     Perform whole-program optimization <x>; see fpc -i or fpc -iw for possible values
  147. *** press enter ***
  148.  
  149.       -Os        Optimize for size rather than speed
  150.   -pg    Generate profile code for gprof (defines FPC_PROFILE)
  151.   -R<x>  Assembler reading style:
  152.       -Rdefault  Use default assembler for target
  153.   -S<x>  Syntax options:
  154.       -S2        Same as -Mobjfpc
  155.       -Sc        Support operators like C (*=,+=,/= and -=)
  156.       -Sa        Turn on assertions
  157.       -Sd        Same as -Mdelphi
  158.       -Se<x>     Error options. <x> is a combination of the following:
  159.          <n> : Compiler halts after the <n> errors (default is 1)
  160.          w : Compiler also halts after warnings
  161.          n : Compiler also halts after notes
  162.          h : Compiler also halts after hints
  163.       -Sf        Enable certain features in compiler and RTL; see fpc -i or fpc -ir for possible values)
  164.       -Sg        Enable LABEL and GOTO (default in -Mtp and -Mdelphi)
  165.       -Sh        Use reference counted strings (ansistring by default) instead of shortstrings
  166.       -Si        Turn on inlining of procedures/functions declared as "inline"
  167.       -Sj        Allows typed constants to be writeable (default in all modes)
  168.       -Sk        Load fpcylix unit
  169. *** press enter ***
  170.  
  171.       -SI<x>     Set interface style to <x>
  172.          -SIcom     COM compatible interface (default)
  173.          -SIcorba   CORBA compatible interface
  174.       -Sm        Support macros like C (global)
  175.       -So        Same as -Mtp
  176.       -Sr        Transparent file names in ISO mode
  177.       -Ss        Constructor name must be init (destructor must be done)
  178.       -Sv        Support vector processing (use CPU vector extensions if available)
  179.       -Sx        Enable exception keywords (default in Delphi/ObjFPC modes)
  180.       -Sy        @<pointer> returns a typed pointer, same as $T+
  181.   -s     Do not call assembler and linker
  182.       -sh        Generate script to link on host
  183.       -st        Generate script to link on target
  184.       -sr        Skip register allocation phase (use with -alr)
  185.   -T<x>  Target operating system:
  186.       -Tembedded Embedded
  187.   -u<x>  Undefines the symbol <x>
  188.   -U     Unit options:
  189.       -Un        Do not check where the unit name matches the file name
  190.       -Ur        Generate release unit files (never automatically recompiled)
  191.       -Us        Compile a system unit
  192. *** press enter ***
  193.  
  194.   -v<x>  Be verbose. <x> is a combination of the following letters:
  195.       e : Show errors (default)       0 : Show nothing (except errors)
  196.       w : Show warnings               u : Show unit info
  197.       n : Show notes                  t : Show tried/used files
  198.       h : Show hints                  c : Show conditionals
  199.       i : Show general info           d : Show debug info
  200.       l : Show linenumbers            r : Rhide/GCC compatibility mode
  201.       s : Show time stamps            q : Show message numbers
  202.       a : Show everything             x : Show info about invoked tools
  203.       b : Write file names messages   p : Write tree.log with parse tree
  204.           with full path              v : Write fpcdebug.txt with
  205.       z : Write output to stderr          lots of debugging info
  206.       m<x>,<y> : Do not show messages numbered <x> and <y>
  207.   -W<x>  Target-specific options (targets)
  208.       -Wp<x>     Specify the controller type; see fpc -i or fpc -iu for possible values
  209.       -WX        Enable executable stack (Linux)
  210.   -X     Executable options:
  211.       -X9        Generate linkerscript for GNU Binutils ld older than version 2.19.1 (Linux)
  212.       -Xc        Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Linux)
  213. *** press enter ***
  214.  
  215.       -Xd        Do not search default library path (sometimes required for cross-compiling when not using -XR)
  216.       -Xe        Use external linker
  217.       -Xf        Substitute pthread library name for linking (BSD)
  218.       -Xg        Create debuginfo in a separate file and add a debuglink section to executable
  219.       -XD        Try to link units dynamically      (defines FPC_LINK_DYNAMIC)
  220.       -Xi        Use internal linker
  221.       -XLA       Define library substitutions for linking
  222.       -XLO       Define order of library linking
  223.       -XLD       Exclude default order of standard libraries
  224.       -Xm        Generate link map
  225.       -XM<x>     Set the name of the 'main' program routine (default is 'main')
  226.       -Xn        Use target system native linker instead of GNU ld (Solaris, AIX)
  227.       -XP<x>     Prepend the binutils names with the prefix <x>
  228.       -Xr<x>     Set the linker's rlink-path to <x> (needed for cross compile, see the ld manual for more information) (BeOS, Linux)
  229.       -XR<x>     Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD, Linux, Mac OS, Solaris)
  230.       -Xs        Strip all symbols from executable
  231. *** press enter ***
  232.  
  233.       -XS        Try to link units statically (default, defines FPC_LINK_STATIC)
  234.       -Xt        Link with static libraries (-static is passed to linker)
  235.       -Xv        Generate table for Virtual Entry calls
  236.       -XV        Use VLink as external linker       (default on Amiga, MorphOS)
  237.       -XX        Try to smartlink units             (defines FPC_LINK_SMART)
  238.  
  239.   -?     Show this help
  240.   -h     Shows this help without waiting

AVR Libc Reference Manual - https://www.microchip.com/webdoc/AVRLibcReferenceManual/group__demo__project_1demo_project_map.html

ccrause

  • Hero Member
  • *****
  • Posts: 1007
Re: Linker map file
« Reply #4 on: January 05, 2020, 05:15:05 pm »
-Xm does indeed not produce a map file, anyway not where I could find it...

You can also try -sh (Generate script to link on host).  As part of the script there is a list of search directories and a list of object files to link.
Code: Text  [Select][+][-]
  1. SEARCH_DIR("/home/christo/fpc/fpc-avr/src/library/")
  2. SEARCH_DIR("./")
  3. SEARCH_DIR("/home/christo/fpc/avr-new/rtl/units/avr-embedded-avr5/")
  4. SEARCH_DIR("/home/christo/fpc/avr-new/compiler/")
  5. INPUT (
  6. /home/christo/fpc/fpc-avr/src/examples/blink1/lib/avr-embedded/blink.o
  7. /home/christo/fpc/avr-new/rtl/units/avr-embedded-avr5/system.o
  8. /home/christo/fpc/avr-new/rtl/units/avr-embedded-avr5/atmega328p.o
  9. /home/christo/fpc/fpc-avr/src/examples/blink1/lib/avr-embedded/delay.o
  10. /home/christo/fpc/fpc-avr/src/examples/blink1/lib/avr-embedded/simavrinfo.o
  11. /home/christo/fpc/fpc-avr/src/examples/blink1/lib/avr-embedded/simavr.o
  12. )
  13. ENTRY(_START)
  14. OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
  15. OUTPUT_ARCH(avr:5)
  16. MEMORY
  17. {
  18. 8<
« Last Edit: January 05, 2020, 05:19:45 pm by ccrause »

ccrause

  • Hero Member
  • *****
  • Posts: 1007
Re: Linker map file
« Reply #5 on: January 05, 2020, 05:29:08 pm »
EDIT : Ah, AVR. I don't have the utilities for AVR target, but does the AVR cross linker support generation of the map file?
avr-ld does report support for a map file:
Code: Text  [Select][+][-]
  1. avr-ld --help | grep -i map
  2.   -M, --print-map             Print map file on standard output
  3.   --map-whole-files           Ignored for gold option compatibility
  4.   --no-map-whole-files        Ignored for gold option compatibility
  5.   -Map FILE                   Write a map file
  6. 8<

This bugreport of mine can be use as an inspiration : https://bugs.freepascal.org/view.php?id=33982
Indeed there is no mention of $MAP in t_embed.pas...

Laksen

  • Hero Member
  • *****
  • Posts: 794
    • J-Software
Re: Linker map file
« Reply #6 on: January 05, 2020, 06:01:51 pm »
I just added support for this, based on Cyrax's patch

julkas

  • Guest
Re: Linker map file
« Reply #7 on: January 06, 2020, 10:04:01 am »
I just added support for this, based on Cyrax's patch
@Laksen Thanks.

 

TinyPortal © 2005-2018