public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/26090]  New: IA-64 creates DT_TEXTREL binaries
@ 2006-02-03 14:42 jakub at gcc dot gnu dot org
  2006-02-03 15:33 ` [Bug target/26090] " rth at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-02-03 14:42 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/26090] IA-64 creates DT_TEXTREL binaries
  2006-02-03 14:42 [Bug target/26090] New: IA-64 creates DT_TEXTREL binaries jakub at gcc dot gnu dot org
@ 2006-02-03 15:33 ` rth at gcc dot gnu dot org
  2006-02-03 19:14 ` rth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2006-02-03 15:33 UTC (permalink / raw)
  To: gcc-bugs



-- 

rth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rth at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-02-03 15:33:52
               date|                            |


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/26090] IA-64 creates DT_TEXTREL binaries
  2006-02-03 14:42 [Bug target/26090] New: IA-64 creates DT_TEXTREL binaries jakub at gcc dot gnu dot org
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2006-02-03 19:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rth at gcc dot gnu dot org  2006-02-03 19:14 -------
Using the hpux definitions is probably the most appropriate way to handle this
for gcc 4.1.  For mainline, it'd be better if we can use actual .rodata for 
static relocations.  Also, alpha has a similar problem, so I may try to
rearrange
things such that we can share code between aix, hpux, ia64, and alpha.


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/26090] IA-64 creates DT_TEXTREL binaries
  2006-02-03 14:42 [Bug target/26090] New: IA-64 creates DT_TEXTREL binaries jakub at gcc dot gnu dot org
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2006-02-03 23:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rth at gcc dot gnu dot org  2006-02-03 23:46 -------
Subject: Bug 26090

Author: rth
Date: Fri Feb  3 23:46:44 2006
New Revision: 110568

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110568
Log:
        PR target/26090
        * config/ia64/sysv4.h (TARGET_ASM_SELECT_RTX_SECTION,
        TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION,
        TARGET_ASM_SELECT_RTX_SECTION, TARGET_RWRELOC): Copy from
        the hpux definition.

Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/ia64/sysv4.h


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/26090] IA-64 creates DT_TEXTREL binaries
  2006-02-03 14:42 [Bug target/26090] New: IA-64 creates DT_TEXTREL binaries jakub at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2007-03-10  0:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rth at gcc dot gnu dot org  2007-03-10 00:53 -------
Subject: Bug 26090

Author: rth
Date: Sat Mar 10 00:53:09 2007
New Revision: 122781

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122781
Log:
        PR target/26090
        * target.h (targetm.asm.out.reloc_rw_mask): New.
        * target-def.h (TARGET_ASM_RELOC_RW_MASK): New.
        (TARGET_ASM_OUT): Use it.
        * targhooks.c, targhooks.h (default_reloc_rw_mask): New.
        * varasm.c (categorize_decl_for_section): Remove shlib argument;
        use the new reloc_rw_mask target hook instead.
        (default_section_type_flags_1): Merge into...
        (default_section_type_flags): ... here.
        (decl_readonly_section_1): Merge into...
        (decl_readonly_section): ... here.
        (default_elf_select_section_1): Merge into...
        (default_elf_select_section): ... here.
        (default_unique_section_1): Merge into...
        (default_unique_section): ... here.
        (compute_reloc_for_rtx_1, compute_reloc_for_rtx): New.
        (default_select_rtx_section): Use it.
        (default_elf_select_rtx_section): Likewise.
        * output.h: Update to match.
        * doc/tm.texi (TARGET_ASM_RELOC_RW_MASK): New.
        * config/alpha/alpha.c (alpha_elf_reloc_rw_mask): New.
        (TARGET_ASM_RELOC_RW_MASK): New.
        * config/i386/i386.c (x86_64_elf_select_section): Adjust call
        to categorize_decl_for_section.
        (x86_64_elf_unique_section): Likewise.
        * config/ia64/hpux.h (TARGET_ASM_SELECT_SECTION,
        TARGET_ASM_UNIQUE_SECTION, TARGET_ASM_SELECT_RTX_SECTION): Remove.
        (TARGET_ASM_RELOC_RW_MASK): New.
        * config/ia64/ia64.c (ia64_rwreloc_select_section,
        ia64_rwreloc_unique_section, ia64_rwreloc_select_rtx_section): Remove.
        (ia64_hpux_reloc_rw_mask, ia64_reloc_rw_mask): New.
        (TARGET_RWRELOC): Remove.
        (ia64_section_type_flags): Adjust call to default_section_type_flags.
        * config/ia64/sysv4.h (TARGET_ASM_RELOC_RW_MASK): New.
        * config/rs6000/rs6000.c (rs6000_elf_section_type_flags): Remove.
        (rs6000_elf_select_section, rs6000_elf_unique_section): Remove.
        (rs6000_elf_reloc_rw_mask, rs6000_xcoff_reloc_rw_mask): New.
        (rs6000_xcoff_select_section): Use decl_readonly_section.
        (rs6000_xcoff_section_type_flags): Use default_section_type_flags.
        * config/rs6000/sysv4.h (TARGET_ASM_RELOC_RW_MASK): New.
        (TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): Remove.
        (TARGET_SECTION_TYPE_FLAGS): Remove.
        * config/rs6000/xcoff.h (TARGET_ASM_RELOC_RW_MASK): New.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/alpha/alpha.c
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/ia64/hpux.h
    trunk/gcc/config/ia64/ia64.c
    trunk/gcc/config/ia64/sysv4.h
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/config/rs6000/sysv4.h
    trunk/gcc/config/rs6000/xcoff.h
    trunk/gcc/doc/tm.texi
    trunk/gcc/output.h
    trunk/gcc/target-def.h
    trunk/gcc/target.h
    trunk/gcc/targhooks.c
    trunk/gcc/targhooks.h
    trunk/gcc/varasm.c


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/26090] IA-64 creates DT_TEXTREL binaries
  2006-02-03 14:42 [Bug target/26090] New: IA-64 creates DT_TEXTREL binaries jakub at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2007-03-10  0:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rth at gcc dot gnu dot org  2007-03-10 00:59 -------
Subject: Bug 26090

Author: rth
Date: Sat Mar 10 00:59:15 2007
New Revision: 122782

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122782
Log:
        PR target/26090
        * target.h (targetm.asm.out.reloc_rw_mask): New.
        * target-def.h (TARGET_ASM_RELOC_RW_MASK): New.
        (TARGET_ASM_OUT): Use it.
        * targhooks.c, targhooks.h (default_reloc_rw_mask): New.
        * varasm.c (categorize_decl_for_section): Remove shlib argument;
        use the new reloc_rw_mask target hook instead.
        (default_section_type_flags_1): Merge into...
        (default_section_type_flags): ... here.
        (decl_readonly_section_1): Merge into...
        (decl_readonly_section): ... here.
        (default_elf_select_section_1): Merge into...
        (default_elf_select_section): ... here.
        (default_unique_section_1): Merge into...
        (default_unique_section): ... here.
        (compute_reloc_for_rtx_1, compute_reloc_for_rtx): New.
        (default_select_rtx_section): Use it.
        (default_elf_select_rtx_section): Likewise.
        * output.h: Update to match.
        * doc/tm.texi (TARGET_ASM_RELOC_RW_MASK): New.
        * config/alpha/alpha.c (alpha_elf_reloc_rw_mask): New.
        (TARGET_ASM_RELOC_RW_MASK): New.
        * config/i386/i386.c (x86_64_elf_select_section): Adjust call
        to categorize_decl_for_section.
        (x86_64_elf_unique_section): Likewise.
        * config/ia64/hpux.h (TARGET_ASM_SELECT_SECTION,
        TARGET_ASM_UNIQUE_SECTION, TARGET_ASM_SELECT_RTX_SECTION): Remove.
        (TARGET_ASM_RELOC_RW_MASK): New.
        * config/ia64/ia64.c (ia64_rwreloc_select_section,
        ia64_rwreloc_unique_section, ia64_rwreloc_select_rtx_section): Remove.
        (ia64_hpux_reloc_rw_mask, ia64_reloc_rw_mask): New.
        (TARGET_RWRELOC): Remove.
        (ia64_section_type_flags): Adjust call to default_section_type_flags.
        * config/ia64/sysv4.h (TARGET_ASM_RELOC_RW_MASK): New.
        * config/rs6000/rs6000.c (rs6000_elf_section_type_flags): Remove.
        (rs6000_elf_select_section, rs6000_elf_unique_section): Remove.
        (rs6000_elf_reloc_rw_mask, rs6000_xcoff_reloc_rw_mask): New.
        (rs6000_xcoff_select_section): Use decl_readonly_section.
        (rs6000_xcoff_section_type_flags): Use default_section_type_flags.
        * config/rs6000/sysv4.h (TARGET_ASM_RELOC_RW_MASK): New.
        (TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): Remove.
        (TARGET_SECTION_TYPE_FLAGS): Remove.
        * config/rs6000/xcoff.h (TARGET_ASM_RELOC_RW_MASK): New.

Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/config/alpha/alpha.c
    branches/gcc-4_2-branch/gcc/config/i386/i386.c
    branches/gcc-4_2-branch/gcc/config/ia64/hpux.h
    branches/gcc-4_2-branch/gcc/config/ia64/ia64.c
    branches/gcc-4_2-branch/gcc/config/ia64/sysv4.h
    branches/gcc-4_2-branch/gcc/config/rs6000/rs6000.c
    branches/gcc-4_2-branch/gcc/config/rs6000/sysv4.h
    branches/gcc-4_2-branch/gcc/config/rs6000/xcoff.h
    branches/gcc-4_2-branch/gcc/doc/tm.texi
    branches/gcc-4_2-branch/gcc/output.h
    branches/gcc-4_2-branch/gcc/target-def.h
    branches/gcc-4_2-branch/gcc/target.h
    branches/gcc-4_2-branch/gcc/targhooks.c
    branches/gcc-4_2-branch/gcc/targhooks.h
    branches/gcc-4_2-branch/gcc/varasm.c


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/26090] IA-64 creates DT_TEXTREL binaries
  2006-02-03 14:42 [Bug target/26090] New: IA-64 creates DT_TEXTREL binaries jakub at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2007-03-11 16:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rth at gcc dot gnu dot org  2007-03-11 16:22 -------
Fixed.


-- 

rth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/26090] IA-64 creates DT_TEXTREL binaries
  2006-02-03 14:42 [Bug target/26090] New: IA-64 creates DT_TEXTREL binaries jakub at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-03-11 16:22 ` rth at gcc dot gnu dot org
@ 2007-03-12 17:16 ` rth at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2007-03-12 17:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rth at gcc dot gnu dot org  2007-03-12 17:15 -------
Subject: Bug 26090

Author: rth
Date: Mon Mar 12 17:15:44 2007
New Revision: 122847

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122847
Log:
        PR target/26090
        * config/alpha/alpha.c (alpha_elf_select_section): New.
        (alpha_elf_unique_section, alpha_elf_section_type_flags): New.
        (alpha_elf_select_rtx_section): Force flag_pic true.
        (TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): New.
        (TARGET_SECTION_TYPE_FLAGS): New.

Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/alpha/alpha.c


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-03-12 17:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-03 14:42 [Bug target/26090] New: IA-64 creates DT_TEXTREL binaries jakub at gcc dot gnu dot org
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

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).