Bug 48032 - PowerPC64 -mcmodel=medium invalid ld offset
Summary: PowerPC64 -mcmodel=medium invalid ld offset
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Alan Modra
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: patch, wrong-code
Depends on:
Blocks:
 
Reported: 2011-03-08 12:58 UTC by Alan Modra
Modified: 2011-03-15 12:59 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc64-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-03-08 13:01:11


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2011-03-08 12:58:45 UTC
/* -fsection-anchors loses the original SYMBOL_REF_DECL when
   replacing memory addresses with an anchor plus offset.
   offsettable_ok_by_alignment assumes the -fsection-anchors code,
   or any symbol_ref without a SYMBOL_REF_DECL is OK, giving:

.L.f:
	addis 9,2,.LANCHOR0@toc@ha
	ld 10,.LANCHOR0@toc@l(9)
	ld 11,.LANCHOR0+8@toc@l(9)
   ...
	.section	.rodata
	.align 1
	.set	.LANCHOR0,. + 0
	.type	BGR233Format, @object
	.size	BGR233Format, 16
BGR233Format:

   Note the byte aligned .rodata which can be linked anywhere, but the
   ld instructions must have .LANCHO0@toc@l at a 4 byte boundary.  */

typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;

typedef struct {
    uint8_t bitsPerPixel;
    uint8_t depth;
    uint8_t bigEndian;
    uint8_t trueColour;
    uint16_t redMax;
    uint16_t greenMax;
    uint16_t blueMax;
    uint8_t redShift;
    uint8_t greenShift;
    uint8_t blueShift;
    uint8_t pad1;
    uint16_t pad2;
} rfbPixelFormat;

struct foo {
    rfbPixelFormat format;
};

static const rfbPixelFormat BGR233Format = {
    8, 8, 0, 1, 7, 7, 3, 0, 3, 6, 0, 0
};

void f (struct foo *p)
{
    p->format = BGR233Format;
}
Comment 1 Alan Modra 2011-03-09 07:55:57 UTC
Author: amodra
Date: Wed Mar  9 07:55:53 2011
New Revision: 170813

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170813
Log:
	PR target/48032
	* config/rs6000/rs6000.c (offsettable_ok_by_alignment): Do not
	presume symbol_refs without a symbol_ref_decl are suitably
	aligned, nor other trees we may see here.  Handle anchor symbols.
	(legitimate_constant_pool_address_p): Comment.  Add mode param.
	Check cmodel=medium addresses.  Adjust all calls.
	(rs6000_emit_move): Don't call offsettable_ok_by_alignment on
	creating cmodel=medium optimized access to locals.
	* config/rs6000/constraints.md (R): Pass QImode to
	legitimate_constant_pool_address_p.
	* config/rs6000/predicates.md (input_operand): Pass mode to
	legitimate_constant_pool_address_p.
	* config/rs6000/rs6000-protos.h (legitimate_constant_pool_address_p):
	Update prototype.


Modified:
    branches/ibm/gcc-4_5-branch/gcc/ChangeLog.ibm
    branches/ibm/gcc-4_5-branch/gcc/config/rs6000/constraints.md
    branches/ibm/gcc-4_5-branch/gcc/config/rs6000/predicates.md
    branches/ibm/gcc-4_5-branch/gcc/config/rs6000/rs6000-protos.h
    branches/ibm/gcc-4_5-branch/gcc/config/rs6000/rs6000.c
Comment 2 Alan Modra 2011-03-15 02:19:32 UTC
Author: amodra
Date: Tue Mar 15 02:19:28 2011
New Revision: 170976

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170976
Log:
	PR target/48032
	* config/rs6000/rs6000.c (offsettable_ok_by_alignment): Do not
	presume symbol_refs without a symbol_ref_decl are suitably
	aligned, nor other trees we may see here.  Handle anchor symbols.
	(legitimate_constant_pool_address_p): Comment.  Add mode param.
	Check cmodel=medium addresses.  Adjust all calls.
	(rs6000_emit_move): Don't call offsettable_ok_by_alignment on
	creating cmodel=medium optimized access to locals.
	* config/rs6000/constraints.md (R): Pass QImode to
	legitimate_constant_pool_address_p.
	* config/rs6000/predicates.md (input_operand): Pass mode to
	legitimate_constant_pool_address_p.
	* config/rs6000/rs6000-protos.h (legitimate_constant_pool_address_p):
	Update prototype.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/constraints.md
    trunk/gcc/config/rs6000/predicates.md
    trunk/gcc/config/rs6000/rs6000-protos.h
    trunk/gcc/config/rs6000/rs6000.c
Comment 3 Alan Modra 2011-03-15 02:27:53 UTC
Author: amodra
Date: Tue Mar 15 02:27:51 2011
New Revision: 170977

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170977
Log:
	PR target/48032
	* config/rs6000/rs6000.c (offsettable_ok_by_alignment): Return
	false for BLKmode and VOIDmode.


Modified:
    branches/ibm/gcc-4_5-branch/gcc/ChangeLog.ibm
    branches/ibm/gcc-4_5-branch/gcc/config/rs6000/rs6000.c
Comment 4 Alan Modra 2011-03-15 12:57:42 UTC
Author: amodra
Date: Tue Mar 15 12:57:37 2011
New Revision: 170990

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170990
Log:
	PR target/48032
	* config/rs6000/rs6000.c (offsettable_ok_by_alignment): Do not
	presume symbol_refs without a symbol_ref_decl are suitably
	aligned, nor other trees we may see here.  Handle anchor symbols.
	(legitimate_constant_pool_address_p): Comment.  Add mode param.
	Check cmodel=medium addresses.  Adjust all calls.
	(rs6000_emit_move): Don't call offsettable_ok_by_alignment on
	creating cmodel=medium optimized access to locals.
	* config/rs6000/constraints.md (R): Pass QImode to
	legitimate_constant_pool_address_p.
	* config/rs6000/predicates.md (input_operand): Pass mode to
	legitimate_constant_pool_address_p.
	* config/rs6000/rs6000-protos.h (legitimate_constant_pool_address_p):
	Update prototype.


Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/rs6000/constraints.md
    branches/gcc-4_6-branch/gcc/config/rs6000/predicates.md
    branches/gcc-4_6-branch/gcc/config/rs6000/rs6000-protos.h
    branches/gcc-4_6-branch/gcc/config/rs6000/rs6000.c
Comment 5 Alan Modra 2011-03-15 12:59:25 UTC
Fixed