xref: /openbmc/openbmc/poky/meta/lib/oe/elf.py (revision c9537f57ab488bf5d90132917b0184e2527970a5)
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                  "loongarch64":( 258,     0,    0,          True,          64),
92                  "mips":       (   8,     0,    0,          False,         32),
93                  "mipsel":     (   8,     0,    0,          True,          32),
94                  "mips64":     (   8,     0,    0,          False,         64),
95                  "mips64el":   (   8,     0,    0,          True,          64),
96                  "microblaze":  (189,     0,    0,          False,         32),
97                  "microblazeel":(189,     0,    0,          True,          32),
98                  "riscv32":    (243,      0,    0,          True,          32),
99                  "riscv64":    (243,      0,    0,          True,          64),
100                  "sh4":        (  42,     0,    0,          True,          32),
101                },
102      "uclinux-uclibc" : {
103                  "bfin":       ( 106,     0,    0,          True,         32),
104                },
105      "linux-gnueabi" : {
106                  "arm" :       (40,     0,    0,          True,          32),
107                  "armeb" :     (40,     0,    0,          False,         32),
108                },
109      "linux-musleabi" : {
110                  "arm" :       (40,     0,    0,          True,          32),
111                  "armeb" :     (40,     0,    0,          False,         32),
112                },
113      "linux-gnuspe" : {
114                  "powerpc":    (20,     0,    0,          False,         32),
115                },
116      "linux-muslspe" : {
117                  "powerpc":    (20,     0,    0,          False,         32),
118                },
119      "linux-gnu" :       {
120                  "powerpc":    (20,     0,    0,          False,         32),
121                  "sh4":        (42,     0,    0,          True,          32),
122                },
123      "linux-gnu_ilp32" :     {
124                  "aarch64" :   (183,    0,    0,          True,          32),
125                },
126      "linux-gnux32" :       {
127                  "x86_64":     (62,     0,    0,          True,          32),
128                },
129      "linux-muslx32" :       {
130                  "x86_64":     (62,     0,    0,          True,          32),
131                },
132      "linux-gnun32" :       {
133                  "mips64":       ( 8,     0,    0,          False,         32),
134                  "mips64el":     ( 8,     0,    0,          True,          32),
135                  "mipsisa64r6":  ( 8,     0,    0,          False,         32),
136                  "mipsisa64r6el":( 8,     0,    0,          True,          32),
137                },
138    }
139
140    # Add in any extra user supplied data which may come from a BSP layer, removing the
141    # need to always change this class directly
142    extra_machdata = (d and d.getVar("PACKAGEQA_EXTRA_MACHDEFFUNCS" or None) or "").split()
143    for m in extra_machdata:
144        call = m + "(machdata, d)"
145        locs = { "machdata" : machine_dict.machdata, "d" : d}
146        machine_dict.machdata = bb.utils.better_eval(call, locs)
147
148  return machine_dict.machdata
149