Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000177 [libFirm] representation crash always 2016-07-18 17:52 2016-07-18 20:58
Reporter tehMillhouse View Status public  
Assigned To
Priority normal Resolution open  
Status new   Product Version
Summary 0000177: Handling of offsets in initializer expressions leads to assembler failing
Description An initializer expression such as

static void * oops[1] = { &oops - 1 };

is represented internally as "Add P(Address P[oops], Const Is<0xFFFFFFFC>)".
This eventually results in the generated assembly being

oops:
    .long oops + 0xfffffffc

Which will fail to assemble if the resulting value doesn't fit into 32 bits (e.g. if there's other static data before this in the file).
(Of course, when using the amd64 backend, the resulting constants are longer, but the problem persists)

I've attached a somewhat minimal example that triggers the problem.
Additional Information
Tags No tags attached.
Attached Files c file icon test.c [^] (199 bytes) 2016-07-18 17:52

- Relationships

-  Notes
(0000271)
Matze (administrator)
2016-07-18 20:58

Converting to an addition with a big positive number is fine as that is semantically equivalent in two-complement arithmetic. So libfirms representation is fine IMO. However reading the gas manual it seems numbers are interpreted as arbitrary precision integers so this will fail. The fix is probably just converting the offset from uint32_t to int32_t before printint it.

(Also technically &oops - 1 is undefined behaviour in your example, but I don't see a reason why it would not work properly in todays libfirm).

- Issue History
Date Modified Username Field Change
2016-07-18 17:52 tehMillhouse New Issue
2016-07-18 17:52 tehMillhouse File Added: test.c
2016-07-18 20:58 Matze Note Added: 0000271


Mantis 1.1.5[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker