xref: /openbmc/openbmc/poky/meta/lib/oe/elf.py (revision 8460358c3d24c71d9d38fd126c745854a6301564)
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: GPL-2.0-only
5#
6
7def machine_dict(d):
8  # Generating this data is slow, so cache it
9  if not hasattr(machine_dict, "machdata"):
10    machine_dict.machdata = {
11      # TARGET_OS  TARGET_ARCH   MACHINE, OSABI, ABIVERSION, Little Endian, 32bit?
12      "darwin9" : {
13                  "arm" :       (40,     0,    0,          True,          32),
14                },
15      "eabi" : {
16                  "arm" :       (40,     0,    0,          True,          32),
17                },
18      "elf" : {
19                  "aarch64" :   (183,    0,    0,          True,          64),
20                  "aarch64_be" :(183,    0,    0,          False,         64),
21                  "i586" :      (3,      0,    0,          True,          32),
22                  "i686" :      (3,      0,    0,          True,          32),
23                  "x86_64":     (62,     0,    0,          True,          64),
24                  "epiphany":   (4643,   0,    0,          True,          32),
25                  "lm32":       (138,    0,    0,          False,         32),
26                  "loongarch64":(258,    0,    0,          True,          64),
27                  "mips":       ( 8,     0,    0,          False,         32),
28                  "mipsel":     ( 8,     0,    0,          True,          32),
29                  "microblaze":  (189,   0,    0,          False,         32),
30                  "microblazeel":(189,   0,    0,          True,          32),
31                  "powerpc":    (20,     0,    0,          False,         32),
32                  "riscv32":    (243,    0,    0,          True,          32),
33                  "riscv64":    (243,    0,    0,          True,          64),
34                },
35      "linux" : {
36                  "aarch64" :   (183,    0,    0,          True,          64),
37                  "aarch64_be" :(183,    0,    0,          False,         64),
38                  "arm" :       (40,    97,    0,          True,          32),
39                  "armeb":      (40,    97,    0,          False,         32),
40                  "powerpc":    (20,     0,    0,          False,         32),
41                  "powerpc64":  (21,     0,    0,          False,         64),
42                  "powerpc64le":  (21,     0,    0,          True,         64),
43                  "i386":       ( 3,     0,    0,          True,          32),
44                  "i486":       ( 3,     0,    0,          True,          32),
45                  "i586":       ( 3,     0,    0,          True,          32),
46                  "i686":       ( 3,     0,    0,          True,          32),
47                  "x86_64":     (62,     0,    0,          True,          64),
48                  "ia64":       (50,     0,    0,          True,          64),
49                  "alpha":      (36902,  0,    0,          True,          64),
50                  "hppa":       (15,     3,    0,          False,         32),
51                  "loongarch64":(258,    0,    0,          True,          64),
52                  "m68k":       ( 4,     0,    0,          False,         32),
53                  "mips":       ( 8,     0,    0,          False,         32),
54                  "mipsel":     ( 8,     0,    0,          True,          32),
55                  "mips64":     ( 8,     0,    0,          False,         64),
56                  "mips64el":   ( 8,     0,    0,          True,          64),
57                  "mipsisa32r6":   ( 8,  0,    0,          False,         32),
58                  "mipsisa32r6el": ( 8,  0,    0,          True,          32),
59                  "mipsisa64r6":   ( 8,  0,    0,          False,         64),
60                  "mipsisa64r6el": ( 8,  0,    0,          True,          64),
61                  "nios2":      (113,    0,    0,          True,          32),
62                  "riscv32":    (243,    0,    0,          True,          32),
63                  "riscv64":    (243,    0,    0,          True,          64),
64                  "s390":       (22,     0,    0,          False,         32),
65                  "sh4":        (42,     0,    0,          True,          32),
66                  "sparc":      ( 2,     0,    0,          False,         32),
67                  "microblaze":  (189,   0,    0,          False,         32),
68                  "microblazeel":(189,   0,    0,          True,          32),
69                },
70      "linux-android" : {
71                  "aarch64" :   (183,    0,    0,          True,          64),
72                  "i686":       ( 3,     0,    0,          True,          32),
73                  "x86_64":     (62,     0,    0,          True,          64),
74                },
75      "linux-androideabi" : {
76                  "arm" :       (40,    97,    0,          True,          32),
77                },
78      "linux-musl" : {
79                  "aarch64" :   (183,    0,    0,            True,          64),
80                  "aarch64_be" :(183,    0,    0,            False,         64),
81                  "arm" :       (  40,    97,    0,          True,          32),
82                  "armeb":      (  40,    97,    0,          False,         32),
83                  "powerpc":    (  20,     0,    0,          False,         32),
84                  "powerpc64":  (  21,     0,    0,          False,         64),
85                  "powerpc64le":  (21,     0,    0,          True,         64),
86                  "i386":       (   3,     0,    0,          True,          32),
87                  "i486":       (   3,     0,    0,          True,          32),
88                  "i586":       (   3,     0,    0,          True,          32),
89                  "i686":       (   3,     0,    0,          True,          32),
90                  "x86_64":     (  62,     0,    0,          True,          64),
91                  "mips":       (   8,     0,    0,          False,         32),
92                  "mipsel":     (   8,     0,    0,          True,          32),
93                  "mips64":     (   8,     0,    0,          False,         64),
94                  "mips64el":   (   8,     0,    0,          True,          64),
95                  "microblaze":  (189,     0,    0,          False,         32),
96                  "microblazeel":(189,     0,    0,          True,          32),
97                  "riscv32":    (243,      0,    0,          True,          32),
98                  "riscv64":    (243,      0,    0,          True,          64),
99                  "sh4":        (  42,     0,    0,          True,          32),
100                },
101      "uclinux-uclibc" : {
102                  "bfin":       ( 106,     0,    0,          True,         32),
103                },
104      "linux-gnueabi" : {
105                  "arm" :       (40,     0,    0,          True,          32),
106                  "armeb" :     (40,     0,    0,          False,         32),
107                },
108      "linux-musleabi" : {
109                  "arm" :       (40,     0,    0,          True,          32),
110                  "armeb" :     (40,     0,    0,          False,         32),
111                },
112      "linux-gnuspe" : {
113                  "powerpc":    (20,     0,    0,          False,         32),
114                },
115      "linux-muslspe" : {
116                  "powerpc":    (20,     0,    0,          False,         32),
117                },
118      "linux-gnu" :       {
119                  "powerpc":    (20,     0,    0,          False,         32),
120                  "sh4":        (42,     0,    0,          True,          32),
121                },
122      "linux-gnu_ilp32" :     {
123                  "aarch64" :   (183,    0,    0,          True,          32),
124                },
125      "linux-gnux32" :       {
126                  "x86_64":     (62,     0,    0,          True,          32),
127                },
128      "linux-muslx32" :       {
129                  "x86_64":     (62,     0,    0,          True,          32),
130                },
131      "linux-gnun32" :       {
132                  "mips64":       ( 8,     0,    0,          False,         32),
133                  "mips64el":     ( 8,     0,    0,          True,          32),
134                  "mipsisa64r6":  ( 8,     0,    0,          False,         32),
135                  "mipsisa64r6el":( 8,     0,    0,          True,          32),
136                },
137    }
138
139    # Add in any extra user supplied data which may come from a BSP layer, removing the
140    # need to always change this class directly
141    extra_machdata = (d and d.getVar("PACKAGEQA_EXTRA_MACHDEFFUNCS" or None) or "").split()
142    for m in extra_machdata:
143        call = m + "(machdata, d)"
144        locs = { "machdata" : machine_dict.machdata, "d" : d}
145        machine_dict.machdata = bb.utils.better_eval(call, locs)
146
147  return machine_dict.machdata
148