On 04/27/2018 08:21 PM, Jan Kiszka wrote:
> On 2018-04-27 11:36, Ralf Ramsauer wrote:
>> This won't drop symbols that are marked as used.
>>
>> The static, relocateable inmate library lib.a is created by ar. When
>> linking executables, unreferenced symbols may be dropped, even if they
>> are attributed as used.
>>
>> --whole-archive ensures that those symbols will be linked.
>>
>> Whereas on x86, we need --gc-sections.
> 
> That's something I do not understand yet: With [1] we will build the
> whole hypervisor, including x86, with --whole-archive, and that works
> fine on x86 as well.

That's what happens if I compile x86 inmates with --whole-archive
instead of --gc-sections:

  LD
/home/ralf/workspace/jailhouse/inmates/demos/x86/32-bit-demo-linked.o
/home/ralf/workspace/jailhouse/inmates/lib/x86/lib32.a(ioapic-32.o): In
function `ioapic_init':
/home/ralf/workspace/jailhouse/inmates/lib/x86/ioapic.c:48: undefined
reference to `map_range'
/home/ralf/workspace/jailhouse/inmates/lib/x86/lib32.a(smp-32.o): In
function `smp_start_cpu':
/home/ralf/workspace/jailhouse/inmates/lib/x86/smp.c:59: undefined
reference to `delay_us'
/home/ralf/workspace/jailhouse/inmates/lib/x86/smp.c:61: undefined
reference to `delay_us'
/home/ralf/workspace/jailhouse/inmates/lib/x86/lib32.a(pci-32.o): In
function `pci_find_device':
/home/ralf/workspace/jailhouse/inmates/lib/x86/../pci.c:47: undefined
reference to `pci_read_config'
/home/ralf/workspace/jailhouse/inmates/lib/x86/../pci.c:51: undefined
reference to `pci_read_config'
/home/ralf/workspace/jailhouse/inmates/lib/x86/lib32.a(pci-32.o): In
function `pci_find_cap':
/home/ralf/workspace/jailhouse/inmates/lib/x86/../pci.c:61: undefined
reference to `pci_read_config'
/home/ralf/workspace/jailhouse/inmates/lib/x86/../pci.c:65: undefined
reference to `pci_read_config'
/home/ralf/workspace/jailhouse/inmates/lib/x86/../pci.c:68: undefined
reference to `pci_read_config'

Interestingly, this only happens to the 32-bit demo inmate.

  Ralf

> 
> Jan
> 
> [1]
> https://www.mail-archive.com/[email protected]/msg04816.html
> 
>>
>> Signed-off-by: Ralf Ramsauer <[email protected]>
>> ---
>>  inmates/Makefile | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/inmates/Makefile b/inmates/Makefile
>> index 595338d5..a8bcf7aa 100644
>> --- a/inmates/Makefile
>> +++ b/inmates/Makefile
>> @@ -21,6 +21,9 @@ INCLUDES := -I$(INMATES_LIB) \
>>  
>>  ifeq ($(subst arm64,arm,$(SRCARCH)),arm)
>>  INCLUDES += -I$(src)/../hypervisor/arch/arm-common/include
>> +LDFLAGS += --whole-archive
>> +else
>> +LDFLAGS += --gc-sections
>>  endif
>>  
>>  LINUXINCLUDE  := $(INCLUDES)
>> @@ -34,7 +37,7 @@ KBUILD_CFLAGS += -include $(INC_CONFIG_H)
>>  endif
>>  
>>  OBJCOPYFLAGS := -O binary
>> -LDFLAGS += --gc-sections -T
>> +LDFLAGS += -T
>>  
>>  subdir-y := lib/$(SRCARCH) demos/$(SRCARCH) tests/$(SRCARCH) 
>> tools/$(SRCARCH)
>>  
>>
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to