🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6307

GCC patch #5

#6307
From: buc
Date: Wed, 13 Dec 1995 00:00
91 lines
4048 bytes
        *varasm.c (in_data_section): Add function
                             Dmitry K. Butskoy   (buc@stu.spb.su)
GCC:    2.7.0

(Our configuration:
        CPU:        mc68030/mc68882
        Computer:   BESTA   (similar to `mot3300 delta')
        System:     SVR3.1  (similar to sysV68)
        asm:        SGS  System V/68 R2V1  syntax  )

    There is `in_text_section()' function in varasm.c . This
function determine  current location is in `text' section.
    There are some reasons to add similar function for the data
section -- `in_data_section()' .

    One of the reasons:
        Some assemblers havn`t `align' psevdo-insn (e.g., my
    assembler has only `even', which allows two-byte alignment).
    But it is possible to emulate `align' by `space' or `org'
    psevdo-insn. For example:

        align       .align  N
        org         .org    ((. - .Lbase) + (N-1)) / N * N
        space       .space  ((. - .Lbase) + (N-1)) / N * N - (. - .Lbase)

        Hear `.' gives a location address in current section,
    `.Lbase' is a start address label in current section. (`.Lbase'
    is used to make (ABS) from  (REL) - (REL) ).
        To make alignment this way in different sections we must use
    different "base" labels for each one (e.g., .Ltext, .Ldata, etc.).
    So, compiler must consider which section is at current location.
        Now GCC can determine the text section, using `in_text_section()'
    from varasm.c . But there is no way to determine another sections.
        I think most actual is to add `in_data_section()' function
    into varasm.c .

`diff -p -c4' for varasm.c:

*** varasm.c    Thu Jun 15 07:12:06 1995
--- varasmNEW.c Wed Dec 13 13:09:11 1995
*************** in_text_section ()
*** 230,237 ****
--- 230,245 ----
  {
    return in_section == in_text;
  }

+ /* Determine if we're in the data section. */
+
+ int
+ in_data_section ()
+ {
+   return in_section == in_data;
+ }
+
  /* Tell assembler to change to section NAME for DECL.
     If DECL is NULL, just switch to section NAME.
     If NAME is NULL, get the name from DECL.  */



    Similar functions for another sections (.ctors, .rodata etc)
can be inserted into varasm.c by a tail of any macro definitions.
E.g.,

    #define CTORS_SECTION_FUNCTION                              \
    void                                                        \
    ctors_section ()                                            \
    {                                                           \
      if (in_section != in_ctors)                               \
        {                                                       \
          fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
          in_section = in_ctors;                                \
        }                                                       \
    }                                                           \
                                                                \
    /* Determine if we're in the ctors section. */              \
                                                                \
    int                                                         \
    in_ctors_section ()                                         \
    {                                                           \
      return in_section == in_ctors;                            \
    }



                        Dmitry K. Butskoy,
                        Saint-Petersburg State Technical University,
                        St. Petersburg, Russia.

                        <buc@stu.spb.su>
Technical Details
Message-ID: <AALphpmuX0@stu.spb.su>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,84a372beb43340fc,start
X-Google-Attributes: gid113d02,public
From: buc@stu.spb.SU
Subject: GCC patch #5
Date: 1995/12/13
Message-ID: <AALphpmuX0@stu.spb.su>
X-Deja-AN: 121757916
distribution: gnu
sender: daemon@cis.ohio-state.edu
organization: State Technical University of St. Petersburg
newsgroups: gnu.gcc.bug