Changeset da13982 in mainline for kernel/meson.build
- Timestamp:
- 2023-10-26T15:20:07Z (15 months ago)
- Branches:
- master, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2fbb42f
- Parents:
- d28bdbe
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-10-26 14:42:03)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-10-26 15:20:07)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/meson.build
rd28bdbe rda13982 41 41 # Defines test_src 42 42 subdir('test') 43 44 ## Cross-platform assembly to start a symtab.data section45 #46 symtab_section = '.section symtab.data, "a", ' + atsign + 'progbits;'47 43 48 44 kernel_include_dirs = include_directories( … … 97 93 endif 98 94 99 if CONFIG_STRIP_BINARIES100 # TODO: do this after disassembling101 kernel_link_args += [ '-s' ]102 endif103 104 95 kernel_c_args = arch_kernel_c_args + kernel_defs + [ 105 96 '-ffreestanding', … … 149 140 all_kernel_objects = [ instrumentables, noninstrumentables ] 150 141 151 # We iterate the build several times to get symbol table right. 152 # Three times is sufficient to get correct even symbols after symtab. 142 kernel_name = 'kernel.elf' 143 kernel_map_name = kernel_name + '.map' 144 kernel_map_path = meson.current_build_dir() / kernel_map_name 145 146 kernel_elf = executable(kernel_name, 147 include_directories: kernel_include_dirs, 148 implicit_include_directories: false, 149 c_args: kernel_c_args, 150 link_args: kernel_c_args + kernel_link_args + [ 151 '-Wl,-Map,' + kernel_map_path, 152 ], 153 link_depends: kernel_ldscript, 154 link_whole: all_kernel_objects, 155 pie: false, 156 ) 157 158 kernel_dbg = custom_target('kernel.dbg', 159 output: 'kernel.dbg', 160 input: kernel_elf, 161 command: [ 162 objcopy, 163 '--only-keep-debug', 164 '@INPUT@', 165 '@OUTPUT@', 166 ], 167 ) 168 169 kernel_elf_stripped = custom_target(kernel_name + '.stripped', 170 output: kernel_name + '.stripped', 171 input: kernel_elf, 172 command: [ 173 objcopy, 174 '--strip-unneeded', 175 '@INPUT@', 176 '@OUTPUT@', 177 ], 178 ) 179 180 rd_init_binaries += [[ kernel_elf_stripped, 'boot/kernel.elf' ]] 181 install_files += [[ 'boot', kernel_elf_stripped.full_path(), 'kernel.elf' ]] 182 install_deps += [ kernel_elf_stripped ] 153 183 154 184 if CONFIG_SYMTAB 155 # Iterate build three times. 156 iterations = [ 1, 2, 3 ] 157 158 # Generates symbol table information as an object file. 159 genmap = find_program('tools/genmap.py') 160 161 # Symbol table dump needed for genmap. 162 kernel_syms = custom_target('kernel_syms.txt', 163 input: all_kernel_objects, 164 output: 'kernel_syms.txt', 165 command: [ objdump, '-t', '@INPUT@' ], 166 capture: true, 167 ) 168 else 169 # Build just once. 170 iterations = [ 1 ] 171 endif 172 173 # Empty symbol map for first iteration. 174 kernel_map_S = custom_target('empty_map.S', 175 output: 'empty_map.S', 176 capture: true, 177 command: [ 'echo', kernel_as_prolog + symtab_section ], 178 ) 179 180 foreach iter : iterations 181 is_last = (iter == iterations.length()) 182 kernel_name = 'kernel.@0@.elf'.format(iter) 183 kernel_map_name = kernel_name + '.map' 184 kernel_map_path = meson.current_build_dir() / kernel_map_name 185 186 kernel_elf = executable(kernel_name, kernel_map_S, 187 include_directories: kernel_include_dirs, 188 implicit_include_directories: false, 189 c_args: kernel_c_args, 190 link_args: kernel_c_args + kernel_link_args + [ 191 '-Wl,-Map,' + kernel_map_path, 192 ], 193 link_depends: kernel_ldscript, 194 link_whole: all_kernel_objects, 195 pie: false, 196 ) 197 198 # Generate symbol table if this is not the final iteration. 199 if not is_last 200 201 # TODO: Teach kernel to read its own ELF symbol table and get rid of this nonsense. 202 # Need to first make sure all architectures (even future ones with dumb bootloaders) can use ELF formatted kernel. 203 204 kernel_map_bin = custom_target(kernel_map_name + '.bin', 205 output: kernel_map_name + '.bin', 206 input: [ kernel_elf, kernel_syms ], 207 command: [ genmap, kernel_map_path, '@INPUT1@', '@OUTPUT@' ], 208 ) 209 210 kernel_map_S_name = kernel_name + '.map.S' 211 212 kernel_map_S = custom_target(kernel_map_S_name, 213 input: kernel_map_bin, 214 output: kernel_map_S_name, 215 capture: true, 216 command: [ 'echo', kernel_as_prolog + symtab_section + ' .incbin "@INPUT@"' ], 217 ) 218 endif 219 endforeach 220 221 rd_init_binaries += [[ kernel_elf, 'boot/kernel.elf' ]] 222 223 install_files += [[ 'boot', kernel_elf.full_path(), 'kernel.elf' ]] 224 install_deps += [ kernel_elf ] 185 rd_init_binaries += [[ kernel_dbg, 'kernel.dbg' ]] 186 install_files += [[ 'boot', kernel_dbg.full_path(), 'kernel.dbg' ]] 187 install_deps += [ kernel_dbg ] 188 endif 225 189 226 190 kernel_disasm = custom_target('kernel.elf.disasm',
Note:
See TracChangeset
for help on using the changeset viewer.