public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
From: Roland McGrath <roland@gnu.ai.mit.edu>
To: arnej@pvv.unit.no
Cc: gas2@cygnus.com
Subject: Re: .gas.warning sections
Date: Sat, 02 Dec 1995 13:49:00 -0000	[thread overview]
Message-ID: <199512022148.QAA14056@churchy.gnu.ai.mit.edu> (raw)
In-Reply-To: <9512022057.AA11248@datter.pvv.unit.no>

> At first, this doesn't get through gcc, I just get
> "section attributes are not supported for this target".  From
> looking at c-common.c this is because ASM_OUTPUT_SECTION_NAME,
> which should mean that the target platform doesn't support
> arbitrarily named sections.

That's right.  This should be defined by the tm.h file.  It seems there is
no existing GCC target which is set up for proper use of ELF on MIPS.

> Now in config/mips the only file defining ASM_OUTPUT_SECTION_NAME
> is elf64.h, which has this code in it:
>
> /* A C statement to output something to the assembler file to switch to section
>    NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
>    NULL_TREE.  Some target formats do not support arbitrary sections.  Do not
>    define this macro in such cases.  */
>
> #define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \
> do {                                                            \
>   extern FILE *asm_out_text_file;                               \
>   if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)              \
>     fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
>   else if ((DECL) && TREE_READONLY (DECL))                      \
>     fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME));     \
>   else                                                          \
>     fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME));    \
> } while (0)

That code also appears in config/svr4.h; its purpose is to select the right
section attributes based on the symbol being defined.  If it is a function,
the section is read-only, executable; if it is a read-only variable, the
section is read-only data; if it is a writable variable, the section is
read/write data.

The @progbits could probably be omitted, but its purpose in the ELF
.section directive is to indicate the type of data in the section is
program data (as opposed to symbols or debugging info or somesuch).

> Stuffing this code into netbsd.h instead seemed to work just as well.
> I would welcome enlightenment on this issue. (Maybe it should
> be common code in config/mips/something.h?)

It would be lovely if there were a config/mips/svr4.h or somesuch, for the
various MIPS platforms that use ELF and SVR4 shared libraries.  Kazumoto
Kojima <kkojima@info.kanagawa-u.ac.jp> may have done some work in this
area, in his port to the mips-gnu platform.

> Another (maybe somewhat irrelevant) inquiry:  With any of the
> two variants above gcc accepts my test file and gas produces an
> object file with the required section.  When linking a 'main'-type
> file which uses the symbol in question (null1 for my example)
> I also get my warning:
> tm.o: In function `main':
> tm.c(.text+0x28): This program uses null1(), which is pointless.
>
> However, if I change my test file to have *only* the warning section
> for null1 (not the function definition itself), I get the following
> behaviour:
>
> gcc: Internal compiler error: program ld got fatal signal 6

This is clearly an ld bug.  Are you using binutils 2.6?  You should report
this bug to bug-gnu-utils so it can be fixed.


  reply	other threads:[~1995-12-02 13:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-12-02 12:57 Arne H. Juul
1995-12-02 13:49 ` Roland McGrath [this message]
1995-12-04  8:25 ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199512022148.QAA14056@churchy.gnu.ai.mit.edu \
    --to=roland@gnu.ai.mit.edu \
    --cc=arnej@pvv.unit.no \
    --cc=gas2@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).