Skip to content

Commit 152e9d4

Browse files
committed
---
yaml --- r: 1355 b: refs/heads/master c: 6063599 h: refs/heads/master i: 1353: 37dfa7d 1351: 3234f01 v: v3
1 parent f07578c commit 152e9d4

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: a1cc5ac63c7d2b7da595cbc31253389a991824bd
2+
refs/heads/master: 60635999f313981abe157318025a19d60d8d310a

trunk/src/boot/be/elf.ml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ let elf32_linux_x86_file
488488
~(entry_name:string)
489489
~(text_frags:(string option, frag) Hashtbl.t)
490490
~(data_frags:(string option, frag) Hashtbl.t)
491+
~(bss_frags:(string option, frag) Hashtbl.t)
491492
~(rodata_frags:(string option, frag) Hashtbl.t)
492493
~(required_fixups:(string, fixup) Hashtbl.t)
493494
~(dwarf:Dwarf.debug_records)
@@ -652,7 +653,7 @@ let elf32_linux_x86_file
652653
(* let gotpltndx = 8L in *) (* Section index of .got.plt *)
653654
(* let relapltndx = 9L in *) (* Section index of .rela.plt *)
654655
let datandx = 10L in (* Section index of .data *)
655-
(* let bssndx = 11L in *) (* Section index of .bss *)
656+
let bssndx = 11L in (* Section index of .bss *)
656657
(* let dynamicndx = 12L in *) (* Section index of .dynamic *)
657658
let shstrtabndx = 13L in (* Section index of .shstrtab *)
658659

@@ -999,6 +1000,22 @@ let elf32_linux_x86_file
9991000
(strtab_entry, symtab_entry)
10001001
in
10011002

1003+
let bss_sym name st_bind fixup =
1004+
let name_fixup = new_fixup ("bss symbol name fixup: '" ^ name ^ "'") in
1005+
let strtab_entry = DEF (name_fixup, ZSTRING name) in
1006+
let symtab_entry =
1007+
symbol
1008+
~string_table_fixup: dynstr_section_fixup
1009+
~name_string_fixup: name_fixup
1010+
~sym_target_fixup: (Some fixup)
1011+
~st_bind
1012+
~st_type: STT_OBJECT
1013+
~st_shndx: bssndx
1014+
in
1015+
incr n_syms;
1016+
(strtab_entry, symtab_entry)
1017+
in
1018+
10021019
let rodata_sym name st_bind fixup =
10031020
let name_fixup = new_fixup ("rodata symbol name fixup: '" ^ name ^ "'") in
10041021
let strtab_entry = DEF (name_fixup, ZSTRING name) in
@@ -1220,6 +1237,12 @@ let elf32_linux_x86_file
12201237
Hashtbl.fold (frags_of_symbol data_sym STB_GLOBAL) data_frags ([],[],[])
12211238
in
12221239

1240+
let (bss_strtab_frags,
1241+
bss_symtab_frags,
1242+
bss_body_frags) =
1243+
Hashtbl.fold (frags_of_symbol bss_sym STB_GLOBAL) bss_frags ([],[],[])
1244+
in
1245+
12231246
let (_,
12241247
require_strtab_frags,
12251248
require_symtab_frags,
@@ -1285,7 +1308,8 @@ let elf32_linux_x86_file
12851308
global_text_symtab_frags @
12861309
local_text_symtab_frags @
12871310
rodata_symtab_frags @
1288-
data_symtab_frags))
1311+
data_symtab_frags @
1312+
bss_symtab_frags))
12891313
in
12901314

12911315
let dynstr_frags = (null_strtab_frag ::
@@ -1294,6 +1318,7 @@ let elf32_linux_x86_file
12941318
local_text_strtab_frags @
12951319
rodata_strtab_frags @
12961320
data_strtab_frags @
1321+
bss_strtab_frags @
12971322
(Array.to_list dynamic_needed_strtab_frags)))
12981323
in
12991324

@@ -1319,7 +1344,7 @@ let elf32_linux_x86_file
13191344
in
13201345
let bss_section =
13211346
DEF (bss_section_fixup,
1322-
SEQ [| |])
1347+
SEQ (Array.of_list bss_body_frags))
13231348
in
13241349
let dynsym_section =
13251350
DEF (dynsym_section_fixup,
@@ -1498,6 +1523,7 @@ let emit_file
14981523
let text_frags = Hashtbl.create 4 in
14991524
let rodata_frags = Hashtbl.create 4 in
15001525
let data_frags = Hashtbl.create 4 in
1526+
let bss_frags = Hashtbl.create 4 in
15011527
let required_fixups = Hashtbl.create 4 in
15021528

15031529
(*
@@ -1630,13 +1656,15 @@ let emit_file
16301656
end
16311657
sem.Semant.ctxt_native_required
16321658
in
1659+
16331660
let all_frags =
16341661
elf32_linux_x86_file
16351662
~sess
16361663
~crate
16371664
~entry_name: "_start"
16381665
~text_frags
16391666
~data_frags
1667+
~bss_frags
16401668
~dwarf
16411669
~sem
16421670
~rodata_frags

0 commit comments

Comments
 (0)