vlm / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
1.05k stars 559 forks source link

BIT_STRING_oer.c not copied and not included in Makefile.am.libasncodec #257

Closed mouse07410 closed 6 years ago

mouse07410 commented 6 years ago

Current master.

Problem

File BIT_STRING_oer.c is not included in the generated Makefile.am.libasncodec, and not copied to the target directory. Example:

$ asn1c -v
ASN.1 Compiler, v0.9.29
Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info> and contributors.
$ asn1c -pdu=Test2b -fwide-types -fbless-SIZE -gen-OER -gen-PER Test2b.asn1 
Compiled Test2b.c
Compiled Test2b.h (contents unchanged)
Copied /opt/local/share/asn1c/OPEN_TYPE.h   -> OPEN_TYPE.h
Copied /opt/local/share/asn1c/OPEN_TYPE.c   -> OPEN_TYPE.c
Copied /opt/local/share/asn1c/constr_CHOICE.h   -> constr_CHOICE.h
Copied /opt/local/share/asn1c/INTEGER.h -> INTEGER.h
Copied /opt/local/share/asn1c/INTEGER.c -> INTEGER.c
Copied /opt/local/share/asn1c/NativeInteger.h   -> NativeInteger.h
Copied /opt/local/share/asn1c/NativeInteger.c   -> NativeInteger.c
Copied /opt/local/share/asn1c/constr_CHOICE.c   -> constr_CHOICE.c
Copied /opt/local/share/asn1c/constr_SEQUENCE.h -> constr_SEQUENCE.h
Copied /opt/local/share/asn1c/constr_SEQUENCE.c -> constr_SEQUENCE.c
Copied /opt/local/share/asn1c/asn_application.h -> asn_application.h
Copied /opt/local/share/asn1c/asn_application.c -> asn_application.c
Copied /opt/local/share/asn1c/asn_ioc.h -> asn_ioc.h
Copied /opt/local/share/asn1c/asn_system.h  -> asn_system.h
Copied /opt/local/share/asn1c/asn_codecs.h  -> asn_codecs.h
Copied /opt/local/share/asn1c/asn_internal.h    -> asn_internal.h
Copied /opt/local/share/asn1c/asn_internal.c    -> asn_internal.c
Copied /opt/local/share/asn1c/asn_random_fill.h -> asn_random_fill.h
Copied /opt/local/share/asn1c/asn_random_fill.c -> asn_random_fill.c
Copied /opt/local/share/asn1c/asn_bit_data.h    -> asn_bit_data.h
Copied /opt/local/share/asn1c/asn_bit_data.c    -> asn_bit_data.c
Copied /opt/local/share/asn1c/OCTET_STRING.h    -> OCTET_STRING.h
Copied /opt/local/share/asn1c/OCTET_STRING.c    -> OCTET_STRING.c
Copied /opt/local/share/asn1c/BIT_STRING.h  -> BIT_STRING.h
Copied /opt/local/share/asn1c/BIT_STRING.c  -> BIT_STRING.c
Copied /opt/local/share/asn1c/asn_codecs_prim.c -> asn_codecs_prim.c
Copied /opt/local/share/asn1c/asn_codecs_prim.h -> asn_codecs_prim.h
Copied /opt/local/share/asn1c/ber_tlv_length.h  -> ber_tlv_length.h
Copied /opt/local/share/asn1c/ber_tlv_length.c  -> ber_tlv_length.c
Copied /opt/local/share/asn1c/ber_tlv_tag.h -> ber_tlv_tag.h
Copied /opt/local/share/asn1c/ber_tlv_tag.c -> ber_tlv_tag.c
Copied /opt/local/share/asn1c/ber_decoder.h -> ber_decoder.h
Copied /opt/local/share/asn1c/ber_decoder.c -> ber_decoder.c
Copied /opt/local/share/asn1c/der_encoder.h -> der_encoder.h
Copied /opt/local/share/asn1c/der_encoder.c -> der_encoder.c
Copied /opt/local/share/asn1c/constr_TYPE.h -> constr_TYPE.h
Copied /opt/local/share/asn1c/constr_TYPE.c -> constr_TYPE.c
Copied /opt/local/share/asn1c/constraints.h -> constraints.h
Copied /opt/local/share/asn1c/constraints.c -> constraints.c
Copied /opt/local/share/asn1c/xer_support.h -> xer_support.h
Copied /opt/local/share/asn1c/xer_support.c -> xer_support.c
Copied /opt/local/share/asn1c/xer_decoder.h -> xer_decoder.h
Copied /opt/local/share/asn1c/xer_decoder.c -> xer_decoder.c
Copied /opt/local/share/asn1c/xer_encoder.h -> xer_encoder.h
Copied /opt/local/share/asn1c/xer_encoder.c -> xer_encoder.c
Copied /opt/local/share/asn1c/per_support.h -> per_support.h
Copied /opt/local/share/asn1c/per_support.c -> per_support.c
Copied /opt/local/share/asn1c/per_decoder.h -> per_decoder.h
Copied /opt/local/share/asn1c/per_decoder.c -> per_decoder.c
Copied /opt/local/share/asn1c/per_encoder.h -> per_encoder.h
Copied /opt/local/share/asn1c/per_encoder.c -> per_encoder.c
Copied /opt/local/share/asn1c/per_opentype.h    -> per_opentype.h
Copied /opt/local/share/asn1c/per_opentype.c    -> per_opentype.c
Copied /opt/local/share/asn1c/oer_decoder.h -> oer_decoder.h
Copied /opt/local/share/asn1c/oer_encoder.h -> oer_encoder.h
Copied /opt/local/share/asn1c/oer_support.h -> oer_support.h
Copied /opt/local/share/asn1c/oer_decoder.c -> oer_decoder.c
Copied /opt/local/share/asn1c/oer_encoder.c -> oer_encoder.c
Copied /opt/local/share/asn1c/oer_support.c -> oer_support.c
Copied /opt/local/share/asn1c/OPEN_TYPE_oer.c   -> OPEN_TYPE_oer.c
Copied /opt/local/share/asn1c/INTEGER_oer.c -> INTEGER_oer.c
Copied /opt/local/share/asn1c/OCTET_STRING_oer.c    -> OCTET_STRING_oer.c
Copied /opt/local/share/asn1c/NativeInteger_oer.c   -> NativeInteger_oer.c
Copied /opt/local/share/asn1c/constr_CHOICE_oer.c   -> constr_CHOICE_oer.c
Copied /opt/local/share/asn1c/constr_SEQUENCE_oer.c -> constr_SEQUENCE_oer.c
Generated Makefile.am.libasncodec
Copied /opt/local/share/asn1c/converter-example.c   -> converter-example.c implicit
Generated converter-example.mk
Copied /opt/local/share/asn1c/converter-example.c   -> converter-example.c implicit
Generated Makefile.am.asn1convert
$ 

As a result, compilation fails:

. . . . .
clang -maes -mpclmul -msse2 -mssse3 -msse4 -msse4.2 -mrdrnd -mrdseed -Os -Ofast -DPDU=Test2b -I. -g3 -o test2b converter-example.c Test2b.o OPEN_TYPE.o INTEGER.o NativeInteger.o constr_CHOICE.o constr_SEQUENCE.o asn_application.o asn_internal.o asn_random_fill.o asn_bit_data.o OCTET_STRING.o BIT_STRING.o asn_codecs_prim.o ber_tlv_length.o ber_tlv_tag.o ber_decoder.o der_encoder.o constr_TYPE.o constraints.o xer_support.o xer_decoder.o xer_encoder.o per_support.o per_decoder.o per_encoder.o per_opentype.o oer_decoder.o oer_encoder.o oer_support.o OPEN_TYPE_oer.o INTEGER_oer.o OCTET_STRING_oer.o NativeInteger_oer.o constr_CHOICE_oer.o constr_SEQUENCE_oer.o  
Undefined symbols for architecture x86_64:
  "_BIT_STRING_decode_oer", referenced from:
      _asn_OP_BIT_STRING in BIT_STRING.o
  "_BIT_STRING_encode_oer", referenced from:
      _asn_OP_BIT_STRING in BIT_STRING.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test2b] Error 1

Also, I tried to figure what component/file in the asn1c source code is responsible for copying the relevant skeleton files, but failed. Could you please point me at the relevant code?

mouse07410 commented 6 years ago

@velichkov maybe you could shed some light? Here's the ASN.1 file:

Test2b DEFINITIONS AUTOMATIC TAGS ::=
BEGIN

Test2b ::= SEQUENCE {

      count INTEGER (40..20000),
      data  OCTET STRING (SIZE (40..20000))
}

END

(I'm sure you've seen it already ;).

For some reason, the current asn1c does not include BIT_STRING_oer.c in the set of copied files. I'm trying to figure out what part of the code was supposed to do that, but so far I'm pulling blanks. Could you help, perhaps?

velichkov commented 6 years ago

Hi @mouse07410,

(I'm sure you've seen it already ;).

No, I haven't. Lately I've been busy with other projects.

For some reason, the current asn1c does not include BIT_STRING_oer.c in the set of copied files.

It does copy it when there is a BIT STRING type in the asn.

Test2b ::= SEQUENCE {
      count INTEGER (40..20000),
      data  OCTET STRING (SIZE (40..20000)),
      bits  BIT STRING { a(1), b(2) }
}

So probably this is some kind of optimization.

I'm trying to figure out what part of the code was supposed to do that, but so far I'm pulling blanks

The code that generate the makefiles and copy skeleton files is in libasn1compiler/asn1c_save.c

I was able to reproduce the problem only when executing manually clang -maes -mpclmul -msse2 -mssse3 -msse4 ...

I'm able to compile and link using the generated converter-example.mk. The difference is that it first generates a static archive libasncodec.a and ten link the converter-example with it.

ar rcs libasncodec.a Test2b.o OPEN_TYPE.o INTEGER.o NativeInteger.o constr_CHOICE.o constr_SEQUENCE.o asn_application.o asn_internal.o asn_random_fill.o asn_bit_data.o OCTET_STRING.o BIT_STRING.o asn_codecs_prim.o ber_tlv_length.o ber_tlv_tag.o ber_decoder.o der_encoder.o constr_TYPE.o constraints.o xer_support.o xer_decoder.o xer_encoder.o per_support.o per_decoder.o per_encoder.o per_opentype.o oer_decoder.o oer_encoder.o oer_support.o OPEN_TYPE_oer.o INTEGER_oer.o OCTET_STRING_oer.o NativeInteger_oer.o constr_CHOICE_oer.o constr_SEQUENCE_oer.o
cc  -DPDU=Test2b -I. -o converter-example.o -c converter-example.c
cc  -DPDU=Test2b -I.  -o converter-example converter-example.o  libasncodec.a -lm
mouse07410 commented 6 years ago

@velichkov you saved my day (and not for the first time ;). Thank you!