@@ -143,6 +143,10 @@ pub(crate) struct SandboxMemoryManager<S: SharedMemory> {
143143 /// The next action to perform when this sandbox resumes:
144144 /// `Initialise` before the guest has run, `Call` afterwards.
145145 pub ( crate ) next_action : NextAction ,
146+ /// Guest virtual address of the guest binary's ELF entry point,
147+ /// preserved across the `Initialise` -> `Call` transition so it
148+ /// can fill `AT_ENTRY` in guest core dumps. 0 if unknown.
149+ pub ( crate ) original_entrypoint : u64 ,
146150 /// Buffer for accumulating guest abort messages
147151 pub ( crate ) abort_buffer : Vec < u8 > ,
148152 /// Generation counter: how many snapshots have been taken from
@@ -283,6 +287,7 @@ where
283287 shared_mem,
284288 scratch_mem,
285289 next_action,
290+ original_entrypoint : 0 ,
286291 abort_buffer : Vec :: new ( ) ,
287292 snapshot_count : 0 ,
288293 }
@@ -315,6 +320,7 @@ where
315320 rsp_gva,
316321 sregs,
317322 next_action,
323+ self . original_entrypoint ,
318324 self . snapshot_count ,
319325 host_functions,
320326 )
@@ -328,6 +334,7 @@ impl SandboxMemoryManager<ExclusiveSharedMemory> {
328334 let scratch_mem = ExclusiveSharedMemory :: new ( s. layout ( ) . get_scratch_size ( ) ) ?;
329335 let next_action = s. next_action ( ) ;
330336 let mut mgr = Self :: new ( layout, shared_mem, scratch_mem, next_action) ;
337+ mgr. original_entrypoint = s. original_entrypoint ( ) ;
331338 // Inherit the snapshot's generation number for the same
332339 // reason `restore_snapshot` does: the guest-visible counter
333340 // reflects "which snapshot is the sandbox currently a clone
@@ -359,6 +366,7 @@ impl SandboxMemoryManager<ExclusiveSharedMemory> {
359366 scratch_mem : hscratch,
360367 layout : self . layout ,
361368 next_action : self . next_action ,
369+ original_entrypoint : self . original_entrypoint ,
362370 abort_buffer : self . abort_buffer ,
363371 snapshot_count : self . snapshot_count ,
364372 } ;
@@ -367,6 +375,7 @@ impl SandboxMemoryManager<ExclusiveSharedMemory> {
367375 scratch_mem : gscratch,
368376 layout : self . layout ,
369377 next_action : self . next_action ,
378+ original_entrypoint : self . original_entrypoint ,
370379 abort_buffer : Vec :: new ( ) , // Guest doesn't need abort buffer
371380 snapshot_count : self . snapshot_count ,
372381 } ;
@@ -504,6 +513,9 @@ impl SandboxMemoryManager<HostSharedMemory> {
504513 // sandbox currently a clone of", not "how many restores have
505514 // happened into this (possibly-reused) partition".
506515 self . snapshot_count = snapshot. snapshot_generation ( ) ;
516+ // Carry the guest ELF entry point across restore so crashdumps
517+ // report the restored image's entry.
518+ self . original_entrypoint = snapshot. original_entrypoint ( ) ;
507519
508520 self . update_scratch_bookkeeping ( ) ?;
509521 Ok ( ( gsnapshot, gscratch) )
0 commit comments