x86-32 binary can not run on 64-bit host

243 views
Skip to first unread message

Cuong Manh Le

unread,
May 23, 2019, 2:12:53 PM5/23/19
to Native-Client-Discuss
Hello,

I build a go program for nacl-386 and it failed to run in 64-bit host:

$ GOOS=nacl GOARCH=386 go build
$ sel_ldr_x86_32 -l /tmp/out -vvvv -S -e ./issue15609.dir
sel_ldr argument list:
sel_ldr_x86_32 -l /tmp/out -vvvv -S -e ./issue15609.dir
Dumping vmmap.
In PrintVmmap
Done.

Checking the log:

[6465,4155476288:00:45:45.211783] Set(0,(nil)) @ix 0: 0x00000000
[6465,4155476288:00:45:45.211912] After @ix 0: 0x00000000, avail_ix 0
[6465,4155476288:00:45:45.212020] Processing I/O redirection/inheritance from environment
[6465,4155476288:00:45:45.212031] NaClAddHostDescriptor: host 6 as nacl desc 0, flag 0x0
[6465,4155476288:00:45:45.212044] NaClRefCountCtor(0x572f2738).
[6465,4155476288:00:45:45.212052] Set(0,0x572f2738) @ix 0: 0x00000000
[6465,4155476288:00:45:45.212060] After @ix 0: 0x00000001, avail_ix 0
[6465,4155476288:00:45:45.212068] NaClAddHostDescriptor: host 7 as nacl desc 1, flag 0x441
[6465,4155476288:00:45:45.212075] NaClRefCountCtor(0x572f2780).
[6465,4155476288:00:45:45.212082] Set(1,0x572f2780) @ix 0: 0x00000001
[6465,4155476288:00:45:45.212089] After @ix 0: 0x00000003, avail_ix 0
[6465,4155476288:00:45:45.212097] NaClAddHostDescriptor: host 8 as nacl desc 2, flag 0x441
[6465,4155476288:00:45:45.212104] NaClRefCountCtor(0x572f27c8).
[6465,4155476288:00:45:45.212113] Set(2,0x572f27c8) @ix 0: 0x00000003
[6465,4155476288:00:45:45.212120] After @ix 0: 0x00000007, avail_ix 0
[6465,4155476288:00:45:45.212127] ... done.
[6465,4155476288:00:45:45.212133] Loading nacl file ./issue15609.dir (non-RPC)
[6465,4155476288:00:45:45.212140] NaClHostDescOpen(0x572f2458, ./issue15609.dir, 0x0, 0x1b6)
[6465,4155476288:00:45:45.212147] NaClHostDescOpen: invoking POSIX open(./issue15609.dir,0x8000,0600)
[6465,4155476288:00:45:45.212161] NaClHostDescOpen: got descriptor 9
[6465,4155476288:00:45:45.212168] NaClHostDescCtor: success.
[6465,4155476288:00:45:45.212175] NaClRefCountCtor(0x572f2818).
[6465,4155476288:00:45:45.212182] Entered NaClAppLoadModule: nap 0x572f1fa8, nexe 0x572f2818
[6465,4155476288:00:45:45.212190] NaClRefCountRef(0x572f2818).
[6465,4155476288:00:45:45.212203] =================================================
[6465,4155476288:00:45:45.212211] Elf header
[6465,4155476288:00:45:45.212217] ==================================================
[6465,4155476288:00:45:45.212223] e_ident+1 = ELF
[6465,4155476288:00:45:45.212230] e_type = 0x2
[6465,4155476288:00:45:45.212237] e_machine = 0x3
[6465,4155476288:00:45:45.212243] e_version = 0x1
[6465,4155476288:00:45:45.212249] e_entry = 0x82a20
[6465,4155476288:00:45:45.212256] e_phoff = 0x34
[6465,4155476288:00:45:45.212262] e_shoff = 0xd4
[6465,4155476288:00:45:45.212269] e_flags = 0
[6465,4155476288:00:45:45.212275] e_ehsize = 0x34
[6465,4155476288:00:45:45.212281] e_phentsize = 0x20
[6465,4155476288:00:45:45.212287] e_phnum = 0x5
[6465,4155476288:00:45:45.212294] e_shentsize = 0x28
[6465,4155476288:00:45:45.212300] e_shnum = 0x19
[6465,4155476288:00:45:45.212306] e_shstrndx = 0x3
[6465,4155476288:00:45:45.212312] sizeof(Elf32_Ehdr) = 0x34
[6465,4155476288:00:45:45.212321] =================================================
[6465,4155476288:00:45:45.212327] Elf Program headers
[6465,4155476288:00:45:45.212334] ==================================================
[6465,4155476288:00:45:45.212340] p_type: 6
[6465,4155476288:00:45:45.212346] p_offset: 34
[6465,4155476288:00:45:45.212353] p_vaddr: 10034
[6465,4155476288:00:45:45.212360] p_paddr: 10034
[6465,4155476288:00:45:45.212366] p_filesz: a0
[6465,4155476288:00:45:45.212372] p_memsz: a0
[6465,4155476288:00:45:45.212379] p_flags: 4
[6465,4155476288:00:45:45.212385]  (PF_R  )
[6465,4155476288:00:45:45.212392] p_align: 10000
[6465,4155476288:00:45:45.212398] 
[6465,4155476288:00:45:45.212404] p_type: 4
[6465,4155476288:00:45:45.212411] p_offset: f9c
[6465,4155476288:00:45:45.212417] p_vaddr: 10f9c
[6465,4155476288:00:45:45.212423] p_paddr: 10f9c
[6465,4155476288:00:45:45.212430] p_filesz: 64
[6465,4155476288:00:45:45.212436] p_memsz: 64
[6465,4155476288:00:45:45.212442] p_flags: 4
[6465,4155476288:00:45:45.212448]  (PF_R  )
[6465,4155476288:00:45:45.212455] p_align: 4
[6465,4155476288:00:45:45.212461] 
[6465,4155476288:00:45:45.212467] p_type: 1
[6465,4155476288:00:45:45.212473] p_offset: 10000
[6465,4155476288:00:45:45.212479] p_vaddr: 20000
[6465,4155476288:00:45:45.212485] p_paddr: 20000
[6465,4155476288:00:45:45.212492] p_filesz: 67020
[6465,4155476288:00:45:45.212506] p_memsz: 67020
[6465,4155476288:00:45:45.212513] p_flags: 5
[6465,4155476288:00:45:45.212520]  (PF_R  PF_X)
[6465,4155476288:00:45:45.212526] p_align: 10000
[6465,4155476288:00:45:45.212533] 
[6465,4155476288:00:45:45.212539] p_type: 1
[6465,4155476288:00:45:45.212545] p_offset: 80000
[6465,4155476288:00:45:45.212551] p_vaddr: 90000
[6465,4155476288:00:45:45.212557] p_paddr: 90000
[6465,4155476288:00:45:45.212564] p_filesz: 59e23
[6465,4155476288:00:45:45.212570] p_memsz: 59e23
[6465,4155476288:00:45:45.212576] p_flags: 4
[6465,4155476288:00:45:45.212582]  (PF_R  )
[6465,4155476288:00:45:45.212589] p_align: 10000
[6465,4155476288:00:45:45.212595] 
[6465,4155476288:00:45:45.212601] p_type: 1
[6465,4155476288:00:45:45.212607] p_offset: e0000
[6465,4155476288:00:45:45.212613] p_vaddr: f0000
[6465,4155476288:00:45:45.212620] p_paddr: f0000
[6465,4155476288:00:45:45.212626] p_filesz: 1720
[6465,4155476288:00:45:45.212632] p_memsz: 143c8
[6465,4155476288:00:45:45.212638] p_flags: 6
[6465,4155476288:00:45:45.212645]  (PF_R PF_W )
[6465,4155476288:00:45:45.212651] p_align: 10000
[6465,4155476288:00:45:45.212657] 
[6465,4155476288:00:45:45.212670] Looking at segment 0, type 0x6, p_flags 0x4
[6465,4155476288:00:45:45.212678] Matched nacl_phdr_check_data[0]
[6465,4155476288:00:45:45.212685] Ignoring
[6465,4155476288:00:45:45.212691] Looking at segment 1, type 0x4, p_flags 0x4
[6465,4155476288:00:45:45.212698] Matched nacl_phdr_check_data[9]
[6465,4155476288:00:45:45.212704] Ignoring
[6465,4155476288:00:45:45.212710] Looking at segment 2, type 0x1, p_flags 0x5
[6465,4155476288:00:45:45.212717] Matched nacl_phdr_check_data[1]
[6465,4155476288:00:45:45.212723] Looking at segment 3, type 0x1, p_flags 0x4
[6465,4155476288:00:45:45.212729] Matched nacl_phdr_check_data[2]
[6465,4155476288:00:45:45.212736] Looking at segment 4, type 0x1, p_flags 0x6
[6465,4155476288:00:45:45.212742] Matched nacl_phdr_check_data[3]
[6465,4155476288:00:45:45.212749] Values from NaClElfImageValidateProgramHeaders:
[6465,4155476288:00:45:45.212755] rodata_start = 0x00090000
[6465,4155476288:00:45:45.212761] rodata_end   = 0x000e9e23
[6465,4155476288:00:45:45.212768] data_start   = 0x000f0000
[6465,4155476288:00:45:45.212774] data_end     = 0x001043c8
[6465,4155476288:00:45:45.212781] max_vaddr    = 0x001043c8
[6465,4155476288:00:45:45.212787] NaClApp addr space layout:
[6465,4155476288:00:45:45.212794] nap->static_text_end    = 0x0000000000087020
[6465,4155476288:00:45:45.212801] nap->dynamic_text_start = 0x0000000000000000
[6465,4155476288:00:45:45.212807] nap->dynamic_text_end   = 0x0000000000000000
[6465,4155476288:00:45:45.212813] nap->rodata_start       = 0x0000000000090000
[6465,4155476288:00:45:45.212820] nap->data_start         = 0x00000000000f0000
[6465,4155476288:00:45:45.212826] nap->data_end           = 0x00000000001043c8
[6465,4155476288:00:45:45.212833] nap->break_addr         = 0x00000000001043c8
[6465,4155476288:00:45:45.212839] nap->initial_entry_pt   = 0x0000000000082a20
[6465,4155476288:00:45:45.212845] nap->user_entry_pt      = 0x0000000000000000
[6465,4155476288:00:45:45.212852] nap->bundle_size        = 0x20
[6465,4155476288:00:45:45.212858] Allocating address space
[6465,4155476288:00:45:45.212865] NaClPerfCounterInterval(NaClAppLoadFile __start__:PreAllocAddrSpace): 667 microsecs
[6465,4155476288:00:45:45.212873] NaClAllocAddrSpace: calling NaClAllocateSpace(*,0x0000000040000000)
[6465,4155476288:00:45:45.212883] NaClFindPrereservedSandboxMemory(, 0x40000000)
[6465,4155476288:00:45:45.212908] NaClPageAllocRandomized: 0xe763dc5c
[6465,4155476288:00:45:45.212915] NaClPageAllocRandomized: hint 0x67630000
[6465,4155476288:00:45:45.212928] NaClAllocateSpace: 67630000, 40000000
[6465,4155476288:00:45:45.212935] Native Client module will be loaded at base address 0x0000000067630000
[6465,4155476288:00:45:45.212942] madvising 0x67740000, 0x3eef0000, MADV_DONTNEED
[6465,4155476288:00:45:45.212959] mprotecting 0x67740000, 0x3eef0000, PROT_NONE
[6465,4155476288:00:45:45.212973] NaClPerfCounterInterval(NaClAppLoadFile PreAllocAddrSpace:*AllocAddrSpace): 107 microsecs
[6465,4155476288:00:45:45.212986] Loading into memory
[6465,4155476288:00:45:45.212999] loading segment 2
[6465,4155476288:00:45:45.213006] NaClElfImageLoad: checking descriptor mmap safety
[6465,4155476288:00:45:45.213013] PReading 421920 (0x67020) bytes to address 0x67650000, position 65536 (0x10000)
[6465,4155476288:00:45:45.213317] loading segment 3
[6465,4155476288:00:45:45.213327] NaClElfImageLoad: checking descriptor mmap safety
[6465,4155476288:00:45:45.213333] PReading 368163 (0x59e23) bytes to address 0x676c0000, position 524288 (0x80000)
[6465,4155476288:00:45:45.213591] loading segment 4
[6465,4155476288:00:45:45.213600] NaClElfImageLoad: checking descriptor mmap safety
[6465,4155476288:00:45:45.213607] PReading 5920 (0x1720) bytes to address 0x67720000, position 917504 (0xe0000)
[6465,4155476288:00:45:45.213623] NaClPerfCounterInterval(NaClAppLoadFile *AllocAddrSpace:*NaClElfImageLoad): 650 microsecs
[6465,4155476288:00:45:45.213631] Replacing gap between static text and (ro)data with shareable memory
[6465,4155476288:00:45:45.213637] NaClMakeDynamicTextShared: shm_vaddr_base = 00087020
[6465,4155476288:00:45:45.213644] NaClMakeDynamicTextShared: shm_vaddr_base = 00090000
[6465,4155476288:00:45:45.213650] shm_upper_bound = 00090000
[6465,4155476288:00:45:45.213657] NaClMakeDynamicTextShared: dynamic_text_size = 0
[6465,4155476288:00:45:45.213663] Empty JITtable region
[6465,4155476288:00:45:45.213670] NaClPerfCounterInterval(NaClAppLoadFile *NaClElfImageLoad:*MakeDynText): 48 microsecs
[6465,4155476288:00:45:45.213677] Filling with halts: 676b7020, 00008fe0 bytes
[6465,4155476288:00:45:45.213710] Validating image
[6465,4155476288:00:45:45.216320] VALIDATION FAILED.
[6465,4155476288:00:45:45.216325] Run sel_ldr in debug mode to ignore validation failure.
[6465,4155476288:00:45:45.216328] Run ncval <module-name> for validation error details.
[6465,4155476288:00:45:45.216330] NaClPerfCounterInterval(NaClAppLoadFile *MakeDynText:*ValidateImg): 2660 microsecs
[6465,4155476288:00:45:45.216333] NaClPerfCounterInterval(NaClAppLoadFile __start__:EndLoadFile): 4135 microsecs
[6465,4155476288:00:45:45.216336] NaClRefCountUnref(0x572f2818).
[6465,4155476288:00:45:45.216339] NaClRefCountUnref(0x572f2818).
[6465,4155476288:00:45:45.216341] NaClDescIoDescDtor(0x572f2818).
[6465,4155476288:00:45:45.216345] NaClRefCountDtor(0x572f2818), refcount 0, destroying.
[6465,4155476288:00:45:45.216348] Error while loading "./issue15609.dir": Validation failure. File violates Native Client safety rules.
Using the wrong type of nexe (nacl-x86-32 on an x86-64 or vice versa)
or a corrupt nexe file may be responsible for this error.
[6465,4155476288:00:45:45.216351] NaClPerfCounterInterval(SelMain __start__:AppLoadEnd): 4687 microsecs
[6465,4155476288:00:45:45.216354] Processing I/O redirection/inheritance from command line
[6465,4155476288:00:45:45.216356] NACL: Application output follows
[6465,4155476288:00:45:45.216358] Entered NaClAppStartModule, nap 0x572f1fa8, start_cb 0x0, instance_data 0x0
[6465,4155476288:00:45:45.216361] NaClAppStartModule: error loading module
[6465,4155476288:00:45:45.216363] Not running app code since errcode is Validation failure. File violates Native Client safety rules. (57) 

So does it mean x86-32 binary does not allow to run on 64-bit host?

If I added `-c` to skip validation, then program run successfully. 
Reply all
Reply to author
Forward
0 new messages