home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / elf / crt / config / i386 / linuxelf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-27  |  8.5 KB  |  239 lines

  1. /* Definitions for Intel 386 running Linux with ELF format
  2.    Written by Eric Youngdale.
  3.    Modified for stabs-in-ELF by H.J. Lu. */
  4.  
  5. /* Use stabs instead of DWARF debug format.  */
  6. #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
  7.  
  8. /* A lie, I guess, but the general idea behind linux/ELF is that we are
  9.    supposed to be outputting something that will assemble under SVr4.
  10.    This gets us pretty close.  */
  11. #include "i386/i386.h"    /* Base i386 target machine definitions */
  12. #include "i386/att.h"    /* Use the i386 AT&T assembler syntax */
  13. #include "svr4.h"
  14. #undef MD_EXEC_PREFIX
  15. #undef MD_STARTFILE_PREFIX
  16. #undef TARGET_VERSION
  17. #define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)");
  18. /* Output at beginning of assembler file.  */
  19. /* The .file command should always begin the output.  */
  20. #undef ASM_FILE_START
  21. #define ASM_FILE_START(FILE)                        \
  22.   do {                                    \
  23.     output_file_directive (FILE, main_input_filename);        \
  24.     fprintf (FILE, "\t.version\t\"01.01\"\n");            \
  25.   } while (0)
  26. /* The svr4 ABI for the i386 says that records and unions are returned
  27.    in memory.  */
  28. #undef DEFAULT_PCC_STRUCT_RETURN
  29. #define DEFAULT_PCC_STRUCT_RETURN 1
  30. /* This is how to output an element of a case-vector that is relative.
  31.    This is only used for PIC code.  See comments by the `casesi' insn in
  32.    i386.md for an explanation of the expression this outputs. */
  33. #undef ASM_OUTPUT_ADDR_DIFF_ELT
  34. #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
  35.   fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
  36. /* Indicate that jump tables go in the text section.  This is
  37.    necessary when compiling PIC code.  */
  38. #define JUMP_TABLES_IN_TEXT_SECTION
  39. /* Copy this from the svr4 specifications... */
  40. /* Define the register numbers to be used in Dwarf debugging information.
  41.    The SVR4 reference port C compiler uses the following register numbers
  42.    in its Dwarf output code:
  43.     0 for %eax (gnu regno = 0)
  44.     1 for %ecx (gnu regno = 2)
  45.     2 for %edx (gnu regno = 1)
  46.     3 for %ebx (gnu regno = 3)
  47.     4 for %esp (gnu regno = 7)
  48.     5 for %ebp (gnu regno = 6)
  49.     6 for %esi (gnu regno = 4)
  50.     7 for %edi (gnu regno = 5)
  51.    The following three DWARF register numbers are never generated by
  52.    the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
  53.    believes these numbers have these meanings.
  54.     8  for %eip    (no gnu equivalent)
  55.     9  for %eflags (no gnu equivalent)
  56.     10 for %trapno (no gnu equivalent)
  57.    It is not at all clear how we should number the FP stack registers
  58.    for the x86 architecture.  If the version of SDB on x86/svr4 were
  59.    a bit less brain dead with respect to floating-point then we would
  60.    have a precedent to follow with respect to DWARF register numbers
  61.    for x86 FP registers, but the SDB on x86/svr4 is so completely
  62.    broken with respect to FP registers that it is hardly worth thinking
  63.    of it as something to strive for compatibility with.
  64.    The verison of x86/svr4 SDB I have at the moment does (partially)
  65.    seem to believe that DWARF register number 11 is associated with
  66.    the x86 register %st(0), but that's about all.  Higher DWARF
  67.    register numbers don't seem to be associated with anything in
  68.    particular, and even for DWARF regno 11, SDB only seems to under-
  69.    stand that it should say that a variable lives in %st(0) (when
  70.    asked via an `=' command) if we said it was in DWARF regno 11,
  71.    but SDB still prints garbage when asked for the value of the
  72.    variable in question (via a `/' command).
  73.    (Also note that the labels SDB prints for various FP stack regs
  74.    when doing an `x' command are all wrong.)
  75.    Note that these problems generally don't affect the native SVR4
  76.    C compiler because it doesn't allow the use of -O with -g and
  77.    because when it is *not* optimizing, it allocates a memory
  78.    location for each floating-point variable, and the memory
  79.    location is what gets described in the DWARF AT_location
  80.    attribute for the variable in question.
  81.    Regardless of the severe mental illness of the x86/svr4 SDB, we
  82.    do something sensible here and we use the following DWARF
  83.    register numbers.  Note that these are all stack-top-relative
  84.    numbers.
  85.     11 for %st(0) (gnu regno = 8)
  86.     12 for %st(1) (gnu regno = 9)
  87.     13 for %st(2) (gnu regno = 10)
  88.     14 for %st(3) (gnu regno = 11)
  89.     15 for %st(4) (gnu regno = 12)
  90.     16 for %st(5) (gnu regno = 13)
  91.     17 for %st(6) (gnu regno = 14)
  92.     18 for %st(7) (gnu regno = 15)
  93. */
  94. #undef DBX_REGISTER_NUMBER
  95. #define DBX_REGISTER_NUMBER(n) \
  96. ((n) == 0 ? 0 \
  97.  : (n) == 1 ? 2 \
  98.  : (n) == 2 ? 1 \
  99.  : (n) == 3 ? 3 \
  100.  : (n) == 4 ? 6 \
  101.  : (n) == 5 ? 7 \
  102.  : (n) == 6 ? 5 \
  103.  : (n) == 7 ? 4 \
  104.  : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
  105.  : (-1))
  106. #define LINUX_ELF
  107. #include "i386/linux.h"
  108.  
  109. #undef YES_UNDERSCORES
  110. #define NO_UNDERSCORES
  111.  
  112.  
  113. /* Output assembler code to FILE to increment profiler label # LABELNO
  114.    for profiling a function entry.  */
  115.  
  116. #undef FUNCTION_PROFILER
  117. #define FUNCTION_PROFILER(FILE, LABELNO)  \
  118. {                                    \
  119.   if (flag_pic)                                \
  120.     {                                    \
  121.       fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n",        \
  122.            LPREFIX, (LABELNO));                    \
  123.       fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");            \
  124.     }                                    \
  125.   else                                    \
  126.     {                                    \
  127.       fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO));    \
  128.       fprintf (FILE, "\tcall mcount\n");                \
  129.     }                                    \
  130. }
  131.  
  132. #undef CPP_PREDEFINES
  133. #define CPP_PREDEFINES "-D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)"
  134.  
  135. #undef CPP_SPEC
  136. #if TARGET_CPU_DEFAULT == 2
  137. #define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE}"
  138. #else
  139. #define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m486:-D__i486__} %{posix:-D_POSIX_SOURCE}"
  140. #endif
  141.  
  142. #if 0
  143.  
  144. #undef LINK_SPEC
  145. #define LINK_SPEC    "-m elf_i386 %{!ibcs:%{!static:%{!dynamic-linker:--dynamic-linker /lib/elf/ld-linux.so.1} %{!rpath:-rpath /lib/elf/}}}"
  146.  
  147. #else
  148.  
  149. #undef    LIB_SPEC
  150. #define LIB_SPEC \
  151.   "%{!shared: \
  152.      %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
  153.        %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
  154.  
  155. #undef    LIB_SPEC_2
  156. #define    LIB_SPEC_2 \
  157.   "%{!shared:-lgcc %L -lgcc}"
  158.  
  159. #undef    LIBGCC_SPEC
  160. #define LIBGCC_SPEC \
  161.   "%{!shared:-lgcc}"
  162.  
  163.  
  164. /* Provide a LINK_SPEC appropriate for Linux.  Here we provide support
  165.    for the special GCC options -static and -shared, which allow us to
  166.    link things in one of these three modes by applying the appropriate
  167.    combinations of options at link-time. We like to support here for
  168.    as many of the other GNU linker options as possible. But I don't
  169.    have the time to search for those flags. I am sure how to add
  170.    support for -soname shared_object_name. H.J.
  171.  
  172.    I took out %{v:%{!V:-V}}. It is too much :-(. They can use
  173.    -Wl,-V.
  174.  
  175.    When the -shared link option is used a final link is not being
  176.    done.  */
  177.  
  178. /* If ELF is the default format, we should not use /lib/elf. */
  179.  
  180. #undef    LINK_SPEC
  181. #ifndef LINUX_DEFAULT_ELF
  182. #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
  183.   %{!shared: \
  184.     %{!ibcs: \
  185.       %{!static: \
  186.     %{rdynamic:-export-dynamic} \
  187.     %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \
  188.     %{!rpath:-rpath /lib/elf/}} %{static:-static}}}"
  189. #else
  190. #define LINK_SPEC "-m elf_i386 %{shared:-shared} \
  191.   %{!shared: \
  192.     %{!ibcs: \
  193.       %{!static: \
  194.     %{rdynamic:-export-dynamic} \
  195.     %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1} \
  196.     %{!rpath:-rpath /lib/}} %{static:-static}}}"
  197. #endif
  198.  
  199. /* Provide a STARTFILE_SPEC appropriate for Linux.  Here we add
  200.    the Linux magical crtbegin.o file (see crtstuff.c) which
  201.    provides part of the support for getting C++ file-scope static
  202.    object constructed before entering `main'. */
  203.    
  204. #undef    STARTFILE_SPEC
  205. #if 0
  206. #define STARTFILE_SPEC \
  207.   "%{!shared: \
  208.      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}} crti.o%s} \
  209.    %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
  210. #else
  211. /* We use crtstuff.c from Jason. It needs crti.o for building the
  212.  * shared library.
  213.  */
  214. #define STARTFILE_SPEC \
  215.   "%{!shared: \
  216.      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
  217.    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
  218. #endif
  219.  
  220. /* Provide a ENDFILE_SPEC appropriate for Linux.  Here we tack on
  221.    the Linux magical crtend.o file (see crtstuff.c) which
  222.    provides part of the support for getting C++ file-scope static
  223.    object constructed before entering `main', followed by a normal
  224.    Linux "finalizer" file, which is either `gcrtn.o' or `crtn.o'.  */
  225.  
  226. #undef    ENDFILE_SPEC
  227. #if 0
  228. #define ENDFILE_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s} \
  229.    %{!shared:crtn.o%s}"
  230. #else
  231. /* We use crtstuff.c from Jason. It needs crtn.o for building the
  232.  * shared library.
  233.  */
  234. #define ENDFILE_SPEC \
  235.   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
  236. #endif
  237.  
  238. #endif
  239.