1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
-- Copyright (C) 2008 Lauri Leukkunen <lle@rahina.org>
-- Licensed under MIT license
-- Here is the necessary plumbing to generate gcc related
-- argv/envp manglings
gcc_compilers = {
"cc",
"gcc",
"c++",
"g++",
"cpp",
"f77",
"g77"
}
-- names, where sbox_cross_gcc_shortversion may be embedded to the name
-- (e.g. gcc-3.4, g++-3.4)
gcc_compilers_with_version = {
"gcc",
"g++",
"cpp"
}
gcc_linkers = {
"ld"
}
gcc_tools = {
"addr2line",
"ar",
"as",
"c++filt",
"gccbug",
"gcov",
"nm",
"objcopy",
"objdump",
"ranlib",
"readelf",
"size",
"strings",
"strip"
}
-- Path prefixes:
-- 1. currently all cross-gcc tools that we are going to replace
-- live in /usr/bin, but these tools may call other tools from
-- the same set (e.g. "gcc" calls "ld", etc). That is why
-- sbox_cross_gcc_dir is needed, too.
-- 2. note that sbox_cross_gcc_dir is not empty, this file
-- won't be loaded at all if it is (see argvenvp.lua),
-- 3. Wrappers for host-* tools live in /sb2/wrappers.
gcc_tools_path_prefixes = {
"/usr/bin/",
sbox_cross_gcc_dir,
"/sb2/"
}
function register_gcc_component_path(tmp)
tmp.path_prefixes = gcc_tools_path_prefixes
argvmods[tmp.name] = tmp
end
function gcc_compiler_arg_mods(tmp)
tmp.add_tail = {}
tmp.remove = {}
if (sbox_cross_gcc_specs_file and sbox_cross_gcc_specs_file ~= "") then
table.insert(tmp.add_tail, "-specs="..sbox_cross_gcc_specs_file)
end
if (sbox_extra_cross_compiler_args and sbox_extra_cross_compiler_args ~= "") then
for gcc_extra in string.gmatch(sbox_extra_cross_compiler_args, "[^ ]+") do
table.insert(tmp.add_tail, gcc_extra)
end
end
if (sbox_extra_cross_compiler_stdinc and sbox_extra_cross_compiler_stdinc ~= "") then
for gcc_stdinc in string.gmatch(sbox_extra_cross_compiler_stdinc, "[^ ]+") do
table.insert(tmp.add_tail, gcc_stdinc)
end
end
if (sbox_block_cross_compiler_args and sbox_block_cross_compiler_args ~= "") then
for gcc_block in string.gmatch(sbox_block_cross_compiler_args, "[^ ]+") do
table.insert(tmp.remove, gcc_block)
end
end
end
-- The trick with ":" .. is to have a non-prefixed gcc call caught here
for prefix in string.gmatch(":" .. sbox_cross_gcc_prefix_list, "[^:]*") do
-- Compiler tools without version suffix
for i = 1, table.maxn(gcc_compilers) do
local tmp = {}
tmp.name = prefix .. gcc_compilers[i]
tmp.new_filename = sbox_cross_gcc_dir .. "/" .. sbox_cross_gcc_subst_prefix .. gcc_compilers[i]
gcc_compiler_arg_mods(tmp)
register_gcc_component_path(tmp)
end
-- Compiler tools with version suffix
for i = 1, table.maxn(gcc_compilers_with_version) do
local tmp = {}
tmp.name = prefix .. gcc_compilers_with_version[i] .. "-" ..
sbox_cross_gcc_shortversion
tmp.new_filename = sbox_cross_gcc_dir .. "/" .. sbox_cross_gcc_subst_prefix .. gcc_compilers_with_version[i]
gcc_compiler_arg_mods(tmp)
register_gcc_component_path(tmp)
end
-- just map the filename for linkers and tools
for i = 1, table.maxn(gcc_linkers) do
local tmp = {}
tmp.name = prefix .. gcc_linkers[i]
tmp.new_filename = sbox_cross_gcc_dir .. "/" .. sbox_cross_gcc_subst_prefix .. gcc_linkers[i]
tmp.add_tail = {}
tmp.remove = {}
if (sbox_extra_cross_ld_args and sbox_extra_cross_ld_args ~= "") then
for ld_extra in string.gmatch(sbox_extra_cross_ld_args, "[^ ]+") do
table.insert(tmp.add_tail, ld_extra)
end
end
if (sbox_block_cross_ld_args and sbox_block_cross_ld_args ~= "") then
for ld_block in string.gmatch(sbox_block_cross_ld_args, "[^ ]+") do
table.insert(tmp.remove, ld_block)
end
end
register_gcc_component_path(tmp)
end
for i = 1, table.maxn(gcc_tools) do
local tmp = {}
tmp.name = prefix .. gcc_tools[i]
tmp.new_filename = sbox_cross_gcc_dir .. "/" .. sbox_cross_gcc_subst_prefix .. gcc_tools[i]
register_gcc_component_path(tmp)
end
end
-- deal with host-gcc functionality, disables mapping
for prefix in string.gmatch(sbox_host_gcc_prefix_list, "[^:]+") do
for i = 1, table.maxn(gcc_compilers) do
local tmp = {}
tmp.name = prefix .. gcc_compilers[i]
tmp.new_filename = sbox_host_gcc_dir .. "/" .. sbox_host_gcc_subst_prefix .. gcc_compilers[i]
tmp.add_tail = {}
tmp.remove = {}
tmp.disable_mapping = 1
if (sbox_extra_host_compiler_args and sbox_extra_host_compiler_args ~= "") then
for gcc_extra in string.gmatch(sbox_extra_host_compiler_args, "[^ ]+") do
table.insert(tmp.add_tail, gcc_extra)
end
end
if (sbox_block_host_compiler_args and sbox_block_host_compiler_args ~= "") then
for gcc_block in string.gmatch(sbox_block_host_compiler_args, "[^ ]+") do
table.insert(tmp.remove, gcc_block)
end
end
register_gcc_component_path(tmp)
end
-- just map the filename for linkers and tools
for i = 1, table.maxn(gcc_linkers) do
local tmp = {}
tmp.name = prefix .. gcc_linkers[i]
tmp.new_filename = sbox_host_gcc_dir .. "/" .. sbox_host_gcc_subst_prefix .. gcc_linkers[i]
tmp.disable_mapping = 1
register_gcc_component_path(tmp)
end
for i = 1, table.maxn(gcc_tools) do
local tmp = {}
tmp.name = prefix .. gcc_tools[i]
tmp.new_filename = sbox_host_gcc_dir .. "/" .. sbox_host_gcc_subst_prefix .. gcc_tools[i]
tmp.disable_mapping = 1
register_gcc_component_path(tmp)
end
end
-- end of gcc related generation
|