Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/bap_llvm/bap_llvm_loader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ let provide_macho_segments =
$ LLVM.segment_cmd_flags
$ LLVM.virtual_segment_cmd) @@
fun (name, off, size) (_,(r,w,x)) (_,addr,vsize) ->
let addr = Int64.(bias + addr) in [
let addr = Int64.(bias + addr) in
provide_if Int64.(size <> 0L) [
Ogre.provide segment addr vsize r w x;
Ogre.provide named_region addr vsize name;
Ogre.provide mapped addr size off;
Expand Down Expand Up @@ -228,7 +229,8 @@ let map_sections_to_segments =
LLVM.section_entry
$ LLVM.section_flags) @@
fun (name,addr,size,off) (_,(r,w,x)) ->
let addr = Int64.(addr + bias) in [
let addr = Int64.(addr + bias) in
provide_if Int64.(size <> 0L) [
Ogre.provide segment addr size r w x >>= fun () ->
Ogre.provide mapped addr size off >>= fun () ->
Ogre.provide named_region addr size name
Expand Down Expand Up @@ -262,7 +264,7 @@ let provide_elf_segments =
$ LLVM.elf_program_header_flags) @@
fun (name,off,size) (_, addr, vsize) (_,ld,r,w,x) ->
let addr = Int64.(addr + bias) in
provide_if ld [
provide_if (ld && Int64.(size <> 0L)) [
Ogre.provide segment addr vsize r w x;
Ogre.provide mapped addr size off;
Ogre.provide named_region addr vsize name;
Expand All @@ -282,14 +284,15 @@ let provide_coff_segmentation = [
$ LLVM.coff_virtual_section_header
$ LLVM.section_flags) @@
fun (name, _, size, start) (_,addr,vsize) (_,(r,w,x)) ->
let addr = Int64.(addr + bias) in [
let addr = Int64.(addr + bias) in
provide_if Int64.(size <> 0L) [
Ogre.provide segment addr vsize r w x;
Ogre.provide mapped addr size start;
Ogre.provide section addr vsize;
Ogre.provide named_region addr vsize name;
] @ provide_if x [
Ogre.provide code_region addr vsize start;
]
Ogre.provide code_region addr vsize start;
]

]

Expand Down
1 change: 1 addition & 0 deletions plugins/primus_loader/primus_loader_basic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ module Make(Param : Param)(Machine : Primus.Machine.S) = struct
| Ok segs ->
Machine.Seq.fold ~init:null segs
~f:(fun endp {Image.Scheme.addr; size; info=(_,w,x)} ->
assert Int64.(size <> 0L);
make_word addr >>= fun lower ->
make_word Int64.(size-1L) >>= fun diff ->
let upper = Word.(lower + diff) in
Expand Down