JUMP_TABLES_IN_TEXT_SECTION
Bernd Schmidt
crux@pool.informatik.rwth-aachen.de
Mon Apr 6 15:25:00 GMT 1998
> The code in shorten_branches went through a major revision about a
> week after you sent this patch. As a result the patch needs to be
> revised to work with the new shorten_branches code.
>
> If you make that update and resend the patch, I'll install it.
Here it is. I've minimally tested it by bootstrapping, make check, and
compiling a small test program with -fpic and without.
The patch is against egcs-980328.
Bernd
* final.c: Define JUMP_TABLES_IN_TEXT_SECTION to a default value
of 0 if it isn't defined.
(shorten_branches, final_scan_insn): Test value
of JUMP_TABLES_IN_TEXT_SECTION instead of just testing whether it
is defined.
* arc/arc.h: Define JUMP_TABLES_IN_TEXT_SECTION to 0.
* m32r/m32r.h: Likewise.
* rs6000/sysv4.h: Likewise.
* arm/coff.h: Define JUMP_TABLES_IN_TEXT_SECTION to 1.
* i386/386bsd.h: Likewise.
* i386/freebsd-elf.h: Likewise.
* i386/freebsd.h: Likewise.
* i386/netbsd.h: Likewise.
* i386/ptx4-i.h: Likewise.
* i386/sysv4.h: Likewise.
* pa/pa.h: Likewise.
* rs6000/linux.h: Likewise.
* rs6000/rs6000.h: Likewise.
* sh/sh.h: Likewise.
* sparc/sp64-elf.h: Likewise.
* v850/v850.h: Likewise.
* i386/linux.h: Define JUMP_TABLES_IN_TEXT_SECTION to (flag_pic).
Index: final.c
diff -c -p -r1.1.1.23 final.c
*** final.c 1998/04/04 16:10:06 1.1.1.23
--- final.c 1998/04/05 11:45:45
*************** Boston, MA 02111-1307, USA. */
*** 115,120 ****
--- 115,124 ----
#define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == ';')
#endif
+ #ifndef JUMP_TABLES_IN_TEXT_SECTION
+ #define JUMP_TABLES_IN_TEXT_SECTION 0
+ #endif
+
/* Nonzero means this function is a leaf function, with no function calls.
This variable exists to be examined in FUNCTION_PROLOGUE
and FUNCTION_EPILOGUE. Always zero, unless set by some action. */
*************** shorten_branches (first)
*** 997,1016 ****
if (max_log < log)
max_log = log;
next = NEXT_INSN (insn);
! /* ADDR_VECs only take room if read-only data goes into the text section. */
! #if !defined(READONLY_DATA_SECTION) || defined(JUMP_TABLES_IN_TEXT_SECTION)
! if (next && GET_CODE (next) == JUMP_INSN)
! {
! rtx nextbody = PATTERN (next);
! if (GET_CODE (nextbody) == ADDR_VEC
! || GET_CODE (nextbody) == ADDR_DIFF_VEC)
! {
! log = ADDR_VEC_ALIGN (next);
! if (max_log < log)
! max_log = log;
! }
! }
#endif
LABEL_TO_ALIGNMENT (insn) = max_log;
max_log = 0;
}
--- 1001,1025 ----
if (max_log < log)
max_log = log;
next = NEXT_INSN (insn);
! /* ADDR_VECs only take room if read-only data goes into the text
! section. */
! if (JUMP_TABLES_IN_TEXT_SECTION
! #if !defined(READONLY_DATA_SECTION)
! || 1
#endif
+ )
+ if (next && GET_CODE (next) == JUMP_INSN)
+ {
+ rtx nextbody = PATTERN (next);
+ if (GET_CODE (nextbody) == ADDR_VEC
+ || GET_CODE (nextbody) == ADDR_DIFF_VEC)
+ {
+ log = ADDR_VEC_ALIGN (next);
+ if (max_log < log)
+ max_log = log;
+ }
+ }
+
LABEL_TO_ALIGNMENT (insn) = max_log;
max_log = 0;
}
*************** shorten_branches (first)
*** 1184,1194 ****
{
/* This only takes room if read-only data goes into the text
section. */
! #if !defined(READONLY_DATA_SECTION) || defined(JUMP_TABLES_IN_TEXT_SECTION)
! insn_lengths[uid] = (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC)
! * GET_MODE_SIZE (GET_MODE (body)));
/* Alignment is handled by ADDR_VEC_ALIGN. */
- #endif
}
else if (asm_noperands (body) >= 0)
insn_lengths[uid] = asm_insn_count (body) * insn_default_length (insn);
--- 1193,1207 ----
{
/* This only takes room if read-only data goes into the text
section. */
! if (JUMP_TABLES_IN_TEXT_SECTION
! #if !defined(READONLY_DATA_SECTION)
! || 1
! #endif
! )
! insn_lengths[uid] = (XVECLEN (body,
! GET_CODE (body) == ADDR_DIFF_VEC)
! * GET_MODE_SIZE (GET_MODE (body)));
/* Alignment is handled by ADDR_VEC_ALIGN. */
}
else if (asm_noperands (body) >= 0)
insn_lengths[uid] = asm_insn_count (body) * insn_default_length (insn);
*************** shorten_branches (first)
*** 1379,1391 ****
PUT_MODE (body, CASE_VECTOR_SHORTEN_MODE (min_addr - rel_addr,
max_addr - rel_addr,
body));
! #if !defined(READONLY_DATA_SECTION) || defined(JUMP_TABLES_IN_TEXT_SECTION)
! insn_lengths[uid]
! = (XVECLEN (body, 1) * GET_MODE_SIZE (GET_MODE (body)));
! insn_current_address += insn_lengths[uid];
! if (insn_lengths[uid] != old_length)
! something_changed = 1;
#endif
continue;
}
#endif /* CASE_VECTOR_SHORTEN_MODE */
--- 1392,1410 ----
PUT_MODE (body, CASE_VECTOR_SHORTEN_MODE (min_addr - rel_addr,
max_addr - rel_addr,
body));
! if (JUMP_TABLES_IN_TEXT_SECTION
! #if !defined(READONLY_DATA_SECTION)
! || 1
#endif
+ )
+ {
+ insn_lengths[uid]
+ = (XVECLEN (body, 1) * GET_MODE_SIZE (GET_MODE (body)));
+ insn_current_address += insn_lengths[uid];
+ if (insn_lengths[uid] != old_length)
+ something_changed = 1;
+ }
+
continue;
}
#endif /* CASE_VECTOR_SHORTEN_MODE */
*************** final_scan_insn (insn, file, optimize, p
*** 2227,2242 ****
if (GET_CODE (nextbody) == ADDR_VEC
|| GET_CODE (nextbody) == ADDR_DIFF_VEC)
{
! #ifndef JUMP_TABLES_IN_TEXT_SECTION
! readonly_data_section ();
#ifdef READONLY_DATA_SECTION
! ASM_OUTPUT_ALIGN (file,
! exact_log2 (BIGGEST_ALIGNMENT
! / BITS_PER_UNIT));
#endif /* READONLY_DATA_SECTION */
! #else /* JUMP_TABLES_IN_TEXT_SECTION */
! function_section (current_function_decl);
! #endif /* JUMP_TABLES_IN_TEXT_SECTION */
#ifdef ASM_OUTPUT_CASE_LABEL
ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
NEXT_INSN (insn));
--- 2246,2263 ----
if (GET_CODE (nextbody) == ADDR_VEC
|| GET_CODE (nextbody) == ADDR_DIFF_VEC)
{
! if (! JUMP_TABLES_IN_TEXT_SECTION)
! {
! readonly_data_section ();
#ifdef READONLY_DATA_SECTION
! ASM_OUTPUT_ALIGN (file,
! exact_log2 (BIGGEST_ALIGNMENT
! / BITS_PER_UNIT));
#endif /* READONLY_DATA_SECTION */
! }
! else
! function_section (current_function_decl);
!
#ifdef ASM_OUTPUT_CASE_LABEL
ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
NEXT_INSN (insn));
Index: tm.texi
diff -c -p -r1.1.3.8 tm.texi
*** tm.texi 1998/02/05 16:43:54 1.1.3.8
--- tm.texi 1998/02/16 21:17:22
*************** data section.
*** 4716,4724 ****
@findex JUMP_TABLES_IN_TEXT_SECTION
@item JUMP_TABLES_IN_TEXT_SECTION
! Define this macro if jump tables (for @code{tablejump} insns) should be
! output in the text section, along with the assembler instructions.
! Otherwise, the readonly data section is used.
This macro is irrelevant if there is no separate readonly data section.
--- 4716,4725 ----
@findex JUMP_TABLES_IN_TEXT_SECTION
@item JUMP_TABLES_IN_TEXT_SECTION
! Define this macro to be an expression with a non-zero value if jump
! tables (for @code{tablejump} insns) should be output in the text
! section, along with the assembler instructions. Otherwise, the
! readonly data section is used.
This macro is irrelevant if there is no separate readonly data section.
Index: config/arc/arc.h
diff -c -p -r1.1.3.3 arc.h
*** config/arc/arc.h 1998/02/05 16:09:36 1.1.3.3
--- config/arc/arc.h 1998/02/16 21:13:54
*************** extern char *arc_text_section,*arc_data_
*** 1173,1179 ****
output in the text section, along with the assembler instructions.
Otherwise, the readonly data section is used.
This macro is irrelevant if there is no separate readonly data section. */
! /*#define JUMP_TABLES_IN_TEXT_SECTION*/
/* Define this macro if references to a symbol must be treated
differently depending on something about the variable or
--- 1173,1179 ----
output in the text section, along with the assembler instructions.
Otherwise, the readonly data section is used.
This macro is irrelevant if there is no separate readonly data section. */
! #define JUMP_TABLES_IN_TEXT_SECTION 0
/* Define this macro if references to a symbol must be treated
differently depending on something about the variable or
Index: config/arm/coff.h
diff -c -p -r1.1.3.2 coff.h
*** config/arm/coff.h 1998/02/05 15:48:53 1.1.3.2
--- config/arm/coff.h 1998/02/16 21:13:43
*************** do { \
*** 104,110 ****
/* Define this macro if jump tables (for `tablejump' insns) should be
output in the text section, along with the assembler instructions.
Otherwise, the readonly data section is used. */
! #define JUMP_TABLES_IN_TEXT_SECTION
#undef READONLY_DATA_SECTION
#define READONLY_DATA_SECTION rdata_section
--- 104,110 ----
/* Define this macro if jump tables (for `tablejump' insns) should be
output in the text section, along with the assembler instructions.
Otherwise, the readonly data section is used. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
#undef READONLY_DATA_SECTION
#define READONLY_DATA_SECTION rdata_section
Index: config/i386/386bsd.h
diff -c -p -r1.1.3.1 386bsd.h
*** config/i386/386bsd.h 1998/02/05 12:32:18 1.1.3.1
--- config/i386/386bsd.h 1998/02/16 21:13:32
***************
*** 69,75 ****
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* Don't default to pcc-struct-return, because gcc is the only compiler, and
we want to retain compatibility with older gcc versions. */
--- 69,75 ----
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* Don't default to pcc-struct-return, because gcc is the only compiler, and
we want to retain compatibility with older gcc versions. */
Index: config/i386/freebsd-elf.h
diff -c -p -r1.1.3.2 freebsd-elf.h
*** config/i386/freebsd-elf.h 1998/02/05 15:49:16 1.1.3.2
--- config/i386/freebsd-elf.h 1998/02/16 21:13:27
*************** Boston, MA 02111-1307, USA. */
*** 38,44 ****
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* Copy this from the svr4 specifications... */
/* Define the register numbers to be used in Dwarf debugging information.
--- 38,44 ----
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* Copy this from the svr4 specifications... */
/* Define the register numbers to be used in Dwarf debugging information.
Index: config/i386/freebsd.h
diff -c -p -r1.1.3.4 freebsd.h
*** config/i386/freebsd.h 1998/02/05 16:44:34 1.1.3.4
--- config/i386/freebsd.h 1998/02/16 21:13:24
*************** Boston, MA 02111-1307, USA. */
*** 81,87 ****
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* Don't default to pcc-struct-return, because gcc is the only compiler, and
we want to retain compatibility with older gcc versions. */
--- 81,87 ----
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* Don't default to pcc-struct-return, because gcc is the only compiler, and
we want to retain compatibility with older gcc versions. */
Index: config/i386/linux.h
diff -c -p -r1.1.3.3 linux.h
*** config/i386/linux.h 1998/02/05 16:01:30 1.1.3.3
--- config/i386/linux.h 1998/02/16 21:13:13
*************** Boston, MA 02111-1307, USA. */
*** 46,52 ****
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* Copy this from the svr4 specifications... */
/* Define the register numbers to be used in Dwarf debugging information.
--- 46,52 ----
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
/* Copy this from the svr4 specifications... */
/* Define the register numbers to be used in Dwarf debugging information.
Index: config/i386/netbsd.h
diff -c -p -r1.1.3.2 netbsd.h
*** config/i386/netbsd.h 1998/02/05 16:17:03 1.1.3.2
--- config/i386/netbsd.h 1998/02/16 21:12:55
***************
*** 50,56 ****
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* Don't default to pcc-struct-return, because gcc is the only compiler, and
we want to retain compatibility with older gcc versions. */
--- 50,56 ----
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* Don't default to pcc-struct-return, because gcc is the only compiler, and
we want to retain compatibility with older gcc versions. */
Index: config/i386/ptx4-i.h
diff -c -p -r1.1.3.1 ptx4-i.h
*** config/i386/ptx4-i.h 1998/02/05 12:32:21 1.1.3.1
--- config/i386/ptx4-i.h 1998/02/16 21:12:48
*************** do { long value[3]; \
*** 244,247 ****
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION
--- 244,247 ----
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
Index: config/i386/sysv4.h
diff -c -p -r1.1.3.1 sysv4.h
*** config/i386/sysv4.h 1998/02/05 12:32:24 1.1.3.1
--- config/i386/sysv4.h 1998/02/16 21:12:41
*************** do { long value[3]; \
*** 242,248 ****
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* A C statement (sans semicolon) to output to the stdio stream
FILE the assembler definition of uninitialized global DECL named
--- 242,248 ----
/* Indicate that jump tables go in the text section. This is
necessary when compiling PIC code. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* A C statement (sans semicolon) to output to the stdio stream
FILE the assembler definition of uninitialized global DECL named
Index: config/m32r/m32r.h
diff -c -p -r1.1.3.3 m32r.h
*** config/m32r/m32r.h 1998/02/05 16:08:57 1.1.3.3
--- config/m32r/m32r.h 1998/02/16 21:12:36
*************** extern void m32r_select_section ();
*** 1390,1396 ****
output in the text section, along with the assembler instructions.
Otherwise, the readonly data section is used.
This macro is irrelevant if there is no separate readonly data section. */
! /*#define JUMP_TABLES_IN_TEXT_SECTION*/
/* Define this macro if references to a symbol must be treated
differently depending on something about the variable or
--- 1390,1396 ----
output in the text section, along with the assembler instructions.
Otherwise, the readonly data section is used.
This macro is irrelevant if there is no separate readonly data section. */
! #define JUMP_TABLES_IN_TEXT_SECTION 0
/* Define this macro if references to a symbol must be treated
differently depending on something about the variable or
Index: config/pa/pa.h
diff -c -p -r1.1.3.6 pa.h
*** config/pa/pa.h 1998/02/05 16:17:37 1.1.3.6
--- config/pa/pa.h 1998/02/16 21:11:05
*************** DTORS_SECTION_FUNCTION
*** 2243,2249 ****
fprintf (FILE, "\tb L$%04d\n\tnop\n", VALUE)
/* Jump tables are executable code and live in the TEXT section on the PA. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* This is how to output an element of a case-vector that is relative.
This must be defined correctly as it is used when generating PIC code.
--- 2243,2249 ----
fprintf (FILE, "\tb L$%04d\n\tnop\n", VALUE)
/* Jump tables are executable code and live in the TEXT section on the PA. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* This is how to output an element of a case-vector that is relative.
This must be defined correctly as it is used when generating PIC code.
Index: config/rs6000/linux.h
*** config/rs6000/linux.h 1998/04/04 15:45:35 1.1.1.8
--- config/rs6000/linux.h 1998/04/05 11:42:46
*************** the Free Software Foundation, 675 Mass A
*** 67,72 ****
#ifndef USE_GNULIBC_1
#define DEFAULT_VTABLE_THUNKS 1
#endif
!
#undef JUMP_TABLES_IN_TEXT_SECTION
#define JUMP_TABLES_IN_TEXT_SECTION
--- 67,72 ----
#ifndef USE_GNULIBC_1
#define DEFAULT_VTABLE_THUNKS 1
#endif
! #define JUMP_TABLES_IN_TEXT_SECTION 1
#undef JUMP_TABLES_IN_TEXT_SECTION
#define JUMP_TABLES_IN_TEXT_SECTION
Index: config/rs6000/rs6000.h
diff -c -p -r1.1.3.6 rs6000.h
*** config/rs6000/rs6000.h 1998/02/05 16:09:23 1.1.3.6
--- config/rs6000/rs6000.h 1998/02/16 21:10:50
*************** extern int rs6000_trunc_used;
*** 2371,2377 ****
/* Indicate that jump tables go in the text section. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* Define the routines to implement these extra sections. */
--- 2371,2377 ----
/* Indicate that jump tables go in the text section. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* Define the routines to implement these extra sections. */
Index: config/rs6000/sysv4.h
diff -c -p -r1.1.1.9 sysv4.h
*** config/rs6000/sysv4.h 1998/04/04 16:12:27 1.1.1.9
--- config/rs6000/sysv4.h 1998/04/05 15:27:09
*************** do { \
*** 330,336 ****
#undef ASM_OUTPUT_EXTERNAL
/* Put jump tables in read-only memory, rather than in .text. */
! #undef JUMP_TABLES_IN_TEXT_SECTION
/* Disable AIX-ism that disables turning -B into -L if the argument specifies a
relative file name. This breaks setting GCC_EXEC_PREFIX to D:\path under
--- 330,336 ----
#undef ASM_OUTPUT_EXTERNAL
/* Put jump tables in read-only memory, rather than in .text. */
! #define JUMP_TABLES_IN_TEXT_SECTION 0
/* Disable AIX-ism that disables turning -B into -L if the argument specifies a
relative file name. This breaks setting GCC_EXEC_PREFIX to D:\path under
Index: config/sh/sh.h
diff -c -p -r1.1.3.5 sh.h
*** config/sh/sh.h 1998/02/05 16:09:26 1.1.3.5
--- config/sh/sh.h 1998/02/16 21:10:30
*************** dtors_section() \
*** 1407,1413 ****
/* Define this so that jump tables go in same section as the current function,
which could be text or it could be a user defined section. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* 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
--- 1407,1413 ----
/* Define this so that jump tables go in same section as the current function,
which could be text or it could be a user defined section. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* 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
Index: config/sparc/sp64-elf.h
diff -c -p -r1.1.3.2 sp64-elf.h
*** config/sparc/sp64-elf.h 1998/02/05 14:32:55 1.1.3.2
--- config/sparc/sp64-elf.h 1998/02/16 21:10:26
*************** crtbegin.o%s \
*** 109,115 ****
tables from other label refs (when we need to). */
/* ??? Revisit this. */
#undef JUMP_TABLES_IN_TEXT_SECTION
! #define JUMP_TABLES_IN_TEXT_SECTION
/* System V Release 4 uses DWARF debugging info.
GDB doesn't support 64 bit stabs yet and the desired debug format is DWARF
--- 109,115 ----
tables from other label refs (when we need to). */
/* ??? Revisit this. */
#undef JUMP_TABLES_IN_TEXT_SECTION
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* System V Release 4 uses DWARF debugging info.
GDB doesn't support 64 bit stabs yet and the desired debug format is DWARF
Index: config/v850/v850.h
diff -c -p -r1.1.3.7 v850.h
*** config/v850/v850.h 1998/02/05 16:45:58 1.1.3.7
--- config/v850/v850.h 1998/02/16 21:10:07
*************** do { char dstr[30]; \
*** 1326,1332 ****
/* The switch instruction requires that the jump table immediately follow
it. */
! #define JUMP_TABLES_IN_TEXT_SECTION
/* svr4.h defines this assuming that 4 byte alignment is required. */
#undef ASM_OUTPUT_BEFORE_CASE_LABEL
--- 1326,1332 ----
/* The switch instruction requires that the jump table immediately follow
it. */
! #define JUMP_TABLES_IN_TEXT_SECTION 1
/* svr4.h defines this assuming that 4 byte alignment is required. */
#undef ASM_OUTPUT_BEFORE_CASE_LABEL
More information about the Gcc
mailing list