Changes in kernel/meson.build [d231a54:c21d4d6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/meson.build
rd231a54 rc21d4d6 42 42 subdir('test') 43 43 44 ## Cross-platform assembly to start a symtab.data section 45 # 46 symtab_section = '.section symtab.data, "a", ' + atsign + 'progbits;' 47 44 48 kernel_include_dirs = include_directories( 45 49 'generic/include', … … 48 52 '..' / 'abi' / 'arch' / KARCH / 'include', 49 53 '..' / 'abi' / 'include', 50 '..' / 'common' / 'include',51 54 'test', 52 55 ) … … 86 89 '-T', meson.current_build_dir() / '_link.ld', 87 90 ] 88 # The kernel is built as ELF but then copied as a blob of bytes and89 # the permissions are not relevant anyway (needed for binutils 2.39+).90 kernel_link_args += ldflags_ignore_rwx_segments91 91 92 92 if CONFIG_LTO … … 94 94 endif 95 95 96 if CONFIG_STRIP_BINARIES 97 # TODO: do this after disassembling 98 kernel_link_args += [ '-s' ] 99 endif 100 96 101 kernel_c_args = arch_kernel_c_args + kernel_defs + [ 97 102 '-ffreestanding', 98 '-fdebug-prefix-map=../../kernel/=', 99 '-fdebug-prefix-map=../../../kernel/=', 100 101 cc.get_supported_arguments([ 102 # TODO: remove this flag 103 '-Wno-cast-function-type', 104 105 # When accessing specific memory addresses that are below 106 # normal page size, the compiler may assume that we actually 107 # dereferenced NULL pointer and warns us about that. 108 # But in kernel we often need to access these addresses 109 # directly hence we need to ignore these warnings. 110 # 111 # TODO: might make more sense to disable this selectively 112 # in specific files (or better yet, for specific lines). 113 '--param=min-pagesize=0', 114 ]), 103 # TODO: remove this flag 104 cc.get_supported_arguments([ '-Wno-cast-function-type' ]), 115 105 ] 116 117 if not CONFIG_LINE_DEBUG118 # Keep the debug info needed to get file names for kernel stack traces.119 kernel_c_args += cc.get_supported_arguments([ '-gdwarf-5', '-g1', '-gno-statement-frontiers' ])120 endif121 106 122 107 if CONFIG_LTO … … 148 133 all_kernel_objects = [ instrumentables, noninstrumentables ] 149 134 150 kernel_name = 'kernel.elf' 151 kernel_map_name = kernel_name + '.map' 152 kernel_map_path = meson.current_build_dir() / kernel_map_name 153 154 kernel_elf = executable(kernel_name, 155 include_directories: kernel_include_dirs, 156 implicit_include_directories: false, 157 c_args: kernel_c_args, 158 link_args: kernel_c_args + kernel_link_args + [ 159 '-Wl,-Map,' + kernel_map_path, 160 ], 161 link_depends: kernel_ldscript, 162 link_whole: all_kernel_objects, 163 pie: false, 164 ) 165 166 kernel_dbg = custom_target('kernel.dbg', 167 output: 'kernel.dbg', 168 input: kernel_elf, 169 command: [ 170 objcopy, 171 '--only-keep-debug', 172 '@INPUT@', 173 '@OUTPUT@', 174 ], 175 ) 176 177 kernel_elf_stripped = custom_target(kernel_name + '.stripped', 178 output: kernel_name + '.stripped', 179 input: kernel_elf, 180 command: [ 181 objcopy, 182 '--strip-unneeded', 183 '@INPUT@', 184 '@OUTPUT@', 185 ], 186 ) 187 188 rd_init_binaries += [[ kernel_elf_stripped, 'boot/kernel.elf' ]] 189 install_files += [[ 'boot', kernel_elf_stripped.full_path(), 'kernel.elf' ]] 190 install_deps += [ kernel_elf_stripped ] 135 # We iterate the build several times to get symbol table right. 136 # Three times is sufficient to get correct even symbols after symtab. 191 137 192 138 if CONFIG_SYMTAB 193 rd_init_binaries += [[ kernel_dbg, 'kernel.dbg' ]] 194 install_files += [[ 'boot', kernel_dbg.full_path(), 'kernel.dbg' ]] 195 install_deps += [ kernel_dbg ] 196 endif 139 # Iterate build three times. 140 iterations = [ 1, 2, 3 ] 141 142 # Generates symbol table information as an object file. 143 genmap = find_program('tools/genmap.py') 144 145 # Symbol table dump needed for genmap. 146 kernel_syms = custom_target('kernel_syms.txt', 147 input: all_kernel_objects, 148 output: 'kernel_syms.txt', 149 command: [ objdump, '-t', '@INPUT@' ], 150 capture: true, 151 ) 152 else 153 # Build just once. 154 iterations = [ 1 ] 155 endif 156 157 # Empty symbol map for first iteration. 158 kernel_map_S = custom_target('empty_map.S', 159 output: 'empty_map.S', 160 capture: true, 161 command: [ 'echo', kernel_as_prolog + symtab_section ], 162 ) 163 164 foreach iter : iterations 165 is_last = (iter == iterations.length()) 166 kernel_name = 'kernel.@0@.elf'.format(iter) 167 kernel_map_name = kernel_name + '.map' 168 kernel_map_path = meson.current_build_dir() / kernel_map_name 169 170 kernel_elf = executable(kernel_name, kernel_map_S, 171 include_directories: kernel_include_dirs, 172 implicit_include_directories: false, 173 c_args: kernel_c_args, 174 link_args: kernel_c_args + kernel_link_args + [ 175 '-Wl,-Map,' + kernel_map_path, 176 ], 177 link_depends: kernel_ldscript, 178 link_whole: all_kernel_objects, 179 pie: false, 180 ) 181 182 # Generate symbol table if this is not the final iteration. 183 if not is_last 184 185 # TODO: Teach kernel to read its own ELF symbol table and get rid of this nonsense. 186 # Need to first make sure all architectures (even future ones with dumb bootloaders) can use ELF formatted kernel. 187 188 kernel_map_bin = custom_target(kernel_map_name + '.bin', 189 output: kernel_map_name + '.bin', 190 input: [ kernel_elf, kernel_syms ], 191 command: [ genmap, kernel_map_path, '@INPUT1@', '@OUTPUT@' ], 192 ) 193 194 kernel_map_S_name = kernel_name + '.map.S' 195 196 kernel_map_S = custom_target(kernel_map_S_name, 197 input: kernel_map_bin, 198 output: kernel_map_S_name, 199 capture: true, 200 command: [ 'echo', kernel_as_prolog + symtab_section + ' .incbin "@INPUT@"' ], 201 ) 202 endif 203 endforeach 204 205 rd_init_binaries += [[ kernel_elf, 'boot/kernel.elf' ]] 206 207 install_files += [[ 'boot', kernel_elf.full_path(), 'kernel.elf' ]] 208 install_deps += [ kernel_elf ] 197 209 198 210 kernel_disasm = custom_target('kernel.elf.disasm',
Note:
See TracChangeset
for help on using the changeset viewer.