public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/26090]  New: IA-64 creates DT_TEXTREL binaries
Date: Fri, 03 Feb 2006 14:42:00 -0000	[thread overview]
Message-ID: <bug-26090-87@http.gcc.gnu.org/bugzilla/> (raw)

int getpid (void), getppid (void);
struct S { int (*p) (void); int (*q) (void); };
const struct S t = { getpid, getppid };
int
main (void)
{
  return 0;
}
gcc -g -o test test.c
or
int foo (void) { return 1; }
int bar (void) { return 2; }
struct S { int (*p) (void); int (*q) (void); };
const struct S t = { foo, bar };
int
main (void)
{
  return 0;
}
gcc -g -o test2 test2.c -Wl,--export-dynamic
results in DT_TEXTREL binaries, which is very bad from security POV.

E.g. SELinux needs to avoid some execmod checks because of this.
I'd say it is far better to use .data.rel.ro and similar sections for such
constants that require relocations rather than .rodata, with -Wl,-z,relro
they will be write protected as well, but no segment will be executable
and writable at the same time that way.

Looking at config/ia64/, it seems hpux is already doing that with:
/* It is illegal to have relocations in shared segments on HPUX.
   Pretend flag_pic is always set.  */
#undef  TARGET_ASM_SELECT_SECTION
#define TARGET_ASM_SELECT_SECTION  ia64_rwreloc_select_section
#undef  TARGET_ASM_UNIQUE_SECTION
#define TARGET_ASM_UNIQUE_SECTION  ia64_rwreloc_unique_section
#undef  TARGET_ASM_SELECT_RTX_SECTION
#define TARGET_ASM_SELECT_RTX_SECTION  ia64_rwreloc_select_rtx_section
#define TARGET_RWRELOC  true

Any reason why this shouldn't be in config/ia64/linux.h as well?


-- 
           Summary: IA-64 creates DT_TEXTREL binaries
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
GCC target triplet: ia64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26090


             reply	other threads:[~2006-02-03 14:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-03 14:42 jakub at gcc dot gnu dot org [this message]
2006-02-03 15:33 ` [Bug target/26090] " rth at gcc dot gnu dot org
2006-02-03 19:14 ` rth at gcc dot gnu dot org
2006-02-03 23:47 ` rth at gcc dot gnu dot org
2007-03-10  0:53 ` rth at gcc dot gnu dot org
2007-03-10  0:59 ` rth at gcc dot gnu dot org
2007-03-11 16:22 ` rth at gcc dot gnu dot org
2007-03-12 17:16 ` rth at gcc dot gnu dot org

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=bug-26090-87@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).