mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-14 02:33:53 +00:00
MC-COFF: Fix Simple and Complex type. Fixes PR8320.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116037 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
290b316a4e
commit
6ab219de7e
@ -139,7 +139,7 @@ namespace COFF {
|
|||||||
IMAGE_SYM_DTYPE_ARRAY = 3, ///< An array of base type.
|
IMAGE_SYM_DTYPE_ARRAY = 3, ///< An array of base type.
|
||||||
|
|
||||||
/// Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
|
/// Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
|
||||||
SCT_COMPLEX_TYPE_SHIFT = 8
|
SCT_COMPLEX_TYPE_SHIFT = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
struct section {
|
struct section {
|
||||||
|
@ -167,7 +167,8 @@ file = ('struct', [
|
|||||||
('Name', ('scalar', '<8s', symname)),
|
('Name', ('scalar', '<8s', symname)),
|
||||||
('Value', ('scalar', '<L', '%d' )),
|
('Value', ('scalar', '<L', '%d' )),
|
||||||
('SectionNumber', ('scalar', '<H', '%d' )),
|
('SectionNumber', ('scalar', '<H', '%d' )),
|
||||||
('SimpleType', ('enum', '<B', '%d', {
|
('_Type', ('scalar', '<H', None )),
|
||||||
|
('SimpleType', ('enum', '& _Type 15', '%d', {
|
||||||
0: 'IMAGE_SYM_TYPE_NULL',
|
0: 'IMAGE_SYM_TYPE_NULL',
|
||||||
1: 'IMAGE_SYM_TYPE_VOID',
|
1: 'IMAGE_SYM_TYPE_VOID',
|
||||||
2: 'IMAGE_SYM_TYPE_CHAR',
|
2: 'IMAGE_SYM_TYPE_CHAR',
|
||||||
@ -184,8 +185,8 @@ file = ('struct', [
|
|||||||
13: 'IMAGE_SYM_TYPE_WORD',
|
13: 'IMAGE_SYM_TYPE_WORD',
|
||||||
14: 'IMAGE_SYM_TYPE_UINT',
|
14: 'IMAGE_SYM_TYPE_UINT',
|
||||||
15: 'IMAGE_SYM_TYPE_DWORD',
|
15: 'IMAGE_SYM_TYPE_DWORD',
|
||||||
})),
|
})), # (Type & 0xF0) >> 4
|
||||||
('ComplexType', ('enum', '<B', '%d', {
|
('ComplexType', ('enum', '>> & _Type 240 4', '%d', {
|
||||||
0: 'IMAGE_SYM_DTYPE_NULL',
|
0: 'IMAGE_SYM_DTYPE_NULL',
|
||||||
1: 'IMAGE_SYM_DTYPE_POINTER',
|
1: 'IMAGE_SYM_DTYPE_POINTER',
|
||||||
2: 'IMAGE_SYM_DTYPE_FUNCTION',
|
2: 'IMAGE_SYM_DTYPE_FUNCTION',
|
||||||
@ -317,7 +318,7 @@ def print_binary_data(size):
|
|||||||
write("%s|%s|\n" % (bytes, text))
|
write("%s|%s|\n" % (bytes, text))
|
||||||
return value
|
return value
|
||||||
|
|
||||||
idlit = re.compile("[a-zA-Z][a-zA-Z0-9_-]*")
|
idlit = re.compile("[a-zA-Z_][a-zA-Z0-9_-]*")
|
||||||
numlit = re.compile("[0-9]+")
|
numlit = re.compile("[0-9]+")
|
||||||
|
|
||||||
def read_value(expr):
|
def read_value(expr):
|
||||||
@ -335,11 +336,6 @@ def read_value(expr):
|
|||||||
if expr == 'false':
|
if expr == 'false':
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if len(token) > 1 and token[0] in ('=', '@', '<', '!', '>'):
|
|
||||||
val = read(expr)
|
|
||||||
assert(len(val) == 1)
|
|
||||||
return val[0]
|
|
||||||
|
|
||||||
if token == '+':
|
if token == '+':
|
||||||
return eval() + eval()
|
return eval() + eval()
|
||||||
if token == '-':
|
if token == '-':
|
||||||
@ -348,6 +344,19 @@ def read_value(expr):
|
|||||||
return eval() * eval()
|
return eval() * eval()
|
||||||
if token == '/':
|
if token == '/':
|
||||||
return eval() / eval()
|
return eval() / eval()
|
||||||
|
if token == '&':
|
||||||
|
return eval() & eval()
|
||||||
|
if token == '|':
|
||||||
|
return eval() | eval()
|
||||||
|
if token == '>>':
|
||||||
|
return eval() >> eval()
|
||||||
|
if token == '<<':
|
||||||
|
return eval() << eval()
|
||||||
|
|
||||||
|
if len(token) > 1 and token[0] in ('=', '@', '<', '!', '>'):
|
||||||
|
val = read(expr)
|
||||||
|
assert(len(val) == 1)
|
||||||
|
return val[0]
|
||||||
|
|
||||||
if idlit.match(token):
|
if idlit.match(token):
|
||||||
return Fields[token]
|
return Fields[token]
|
||||||
@ -373,6 +382,8 @@ def write_value(format,value):
|
|||||||
elif format_type is types.TupleType:
|
elif format_type is types.TupleType:
|
||||||
Fields['this'] = value
|
Fields['this'] = value
|
||||||
handle_element(format)
|
handle_element(format)
|
||||||
|
elif format_type is types.NoneType:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("unexpected type: %s" % repr(format_type))
|
raise RuntimeError("unexpected type: %s" % repr(format_type))
|
||||||
|
|
||||||
@ -448,10 +459,12 @@ def handle_struct(entry):
|
|||||||
name = member[0]
|
name = member[0]
|
||||||
type = member[1]
|
type = member[1]
|
||||||
|
|
||||||
write("%s = "%name.ljust(24))
|
if name[0] != "_":
|
||||||
|
write("%s = " % name.ljust(24))
|
||||||
|
|
||||||
value = handle_element(type)
|
value = handle_element(type)
|
||||||
|
|
||||||
|
if name[0] != "_":
|
||||||
write("\n")
|
write("\n")
|
||||||
|
|
||||||
Fields[name] = value
|
Fields[name] = value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user