1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
|
/*******************************************************************/
/* slibtool: a skinny libtool implementation, written in C */
/* Copyright (C) 2016 Z. Gilboa */
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
/*******************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
#include <slibtool/slibtool.h>
#include "slibtool_spawn_impl.h"
#include "slibtool_symlink_impl.h"
struct slbt_deps_meta {
char ** altv;
char * args;
int depscnt;
int infolen;
};
/*******************************************************************/
/* */
/* -o <ltlib> switches input result */
/* ---------- --------------------- ----- ------ */
/* libfoo.a [-shared|-static] bar.lo libfoo.a */
/* */
/* ar cru libfoo.a bar.o */
/* ranlib libfoo.a */
/* */
/*******************************************************************/
/*******************************************************************/
/* */
/* -o <ltlib> switches input result */
/* ---------- --------------------- ----- ------ */
/* libfoo.la -shared bar.lo libfoo.la */
/* .libs/libfoo.a */
/* .libs/libfoo.la (lnk) */
/* */
/* ar cru .libs/libfoo.a .libs/bar.o */
/* ranlib .libs/libfoo.a */
/* (generate libfoo.la) */
/* ln -s ../libfoo.la .libs/libfoo.la */
/* */
/*******************************************************************/
/*******************************************************************/
/* */
/* -o <ltlib> switches input result */
/* ---------- --------------------- ----- ------ */
/* libfoo.la -static bar.lo libfoo.la */
/* .libs/libfoo.a */
/* .libs/libfoo.la (lnk) */
/* */
/* ar cru .libs/libfoo.a bar.o */
/* ranlib .libs/libfoo.a */
/* (generate libfoo.la) */
/* ln -s ../libfoo.la .libs/libfoo.la */
/* */
/*******************************************************************/
static int slbt_get_deps_meta(
char * libfilename,
struct slbt_deps_meta * depsmeta)
{
int ret;
FILE * fdeps;
struct stat st;
char depfile[4*PATH_MAX];
char * deplibs = depfile;
if ((size_t)snprintf(depfile,sizeof(depfile),"%s.slibtool.deps",
libfilename)
>= sizeof(depfile))
return -1;
if ((stat(depfile,&st)))
return -1;
if (!(fdeps = fopen(depfile,"r")))
return -1;
if ((size_t)st.st_size >= sizeof(depfile))
if (!(deplibs = malloc(st.st_size+1))) {
fclose(fdeps);
return -1;
}
depsmeta->infolen += st.st_size;
depsmeta->infolen++;
while (fscanf(fdeps,"%s\n",deplibs) == 1)
depsmeta->depscnt++;
ret = ferror(fdeps) ? -1 : 0;
fclose(fdeps);
return ret;
}
static bool slbt_adjust_input_argument(
char * arg,
const char * osuffix,
const char * asuffix,
bool fpic)
{
char * slash;
char * dot;
char base[PATH_MAX];
if (*arg == '-')
return false;
if (!(dot = strrchr(arg,'.')))
return false;
if (strcmp(dot,osuffix))
return false;
if (fpic) {
if ((slash = strrchr(arg,'/')))
slash++;
else
slash = arg;
if ((size_t)snprintf(base,sizeof(base),"%s",
slash) >= sizeof(base))
return false;
sprintf(slash,".libs/%s",base);
dot = strrchr(arg,'.');
}
strcpy(dot,asuffix);
return true;
}
static int slbt_adjust_linker_argument(
char * arg,
bool fpic,
const char * dsosuffix,
const char * arsuffix,
struct slbt_deps_meta * depsmeta)
{
int fdlib;
char * slash;
char * dot;
char base[PATH_MAX];
if (*arg == '-')
return 0;
if (!(dot = strrchr(arg,'.')))
return 0;
if (strcmp(dot,".la"))
return 0;
if (fpic) {
if ((slash = strrchr(arg,'/')))
slash++;
else
slash = arg;
if ((size_t)snprintf(base,sizeof(base),"%s",
slash) >= sizeof(base))
return 0;
sprintf(slash,".libs/%s",base);
dot = strrchr(arg,'.');
}
/* shared library dependency? */
if (fpic) {
sprintf(dot,"%s",dsosuffix);
if ((fdlib = open(arg,O_RDONLY)) >= 0)
close(fdlib);
else
sprintf(dot,"%s",arsuffix);
return slbt_get_deps_meta(arg,depsmeta);
}
/* input archive */
sprintf(dot,"%s",arsuffix);
return 0;
}
static int slbt_exec_link_adjust_argument_vector(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
const char * cwd,
bool flibrary)
{
char ** carg;
char ** aarg;
char * slash;
char * mark;
char * dot;
char arg[PATH_MAX];
bool fwholearchive = false;
carg = ectx->cargv;
aarg = ectx->altv;
for (; *carg; ) {
if (!strcmp(*carg,"-Wl,--whole-archive"))
fwholearchive = true;
else if (!strcmp(*carg,"-Wl,--no-whole-archive"))
fwholearchive = false;
if (**carg == '-') {
*aarg++ = *carg++;
} else if (!(dot = strrchr(*carg,'.'))) {
*aarg++ = *carg++;
} else if (!(strcmp(dot,".a"))) {
if (flibrary && !fwholearchive)
*aarg++ = "-Wl,--whole-archive";
*aarg++ = *carg++;
if (flibrary && !fwholearchive)
*aarg++ = "-Wl,--no-whole-archive";
} else if (strcmp(dot,dctx->cctx->settings.dsosuffix)) {
*aarg++ = *carg++;
} else if (carg == ectx->lout[1]) {
/* ^^^hoppla^^^ */
*aarg++ = *carg++;
} else {
/* account for {'-','L','-','l'} */
if ((size_t)snprintf(arg,sizeof(arg),"%s",
*carg) >= (sizeof(arg) - 4))
return -1;
if ((slash = strrchr(arg,'/'))) {
sprintf(*carg,"-L%s",arg);
mark = strrchr(*carg,'/');
*mark = '\0';
if (ectx->fwrapper) {
*slash = '\0';
if (fprintf(ectx->fwrapper,
"DL_PATH=\"$DL_PATH$COLON%s/%s\"\n"
"COLON=':'\n\n",
cwd,arg) < 0)
return -1;
}
*aarg++ = *carg++;
*aarg++ = ++mark;
++slash;
slash += strlen(dctx->cctx->settings.dsoprefix);
sprintf(mark,"-l%s",slash);
dot = strrchr(mark,'.');
*dot = '\0';
} else {
*aarg++ = *carg++;
}
}
}
return 0;
}
static int slbt_exec_link_remove_file(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
const char * target)
{
/* remove target (if any) */
if (!(unlink(target)) || (errno == ENOENT))
return 0;
if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT))
strerror(errno);
return -1;
}
static int slbt_exec_link_create_dep_file(
struct slbt_exec_ctx * ectx,
char ** altv,
const char * libfilename)
{
char ** parg;
char * popt;
char * plib;
char depfile[PATH_MAX];
if (ectx->fdeps)
fclose(ectx->fdeps);
if ((size_t)snprintf(depfile,sizeof(depfile),"%s.slibtool.deps",
libfilename)
>= sizeof(depfile))
return -1;
if (!(ectx->fdeps = fopen(depfile,"w")))
return -1;
for (parg=altv; *parg; parg++) {
popt = 0;
plib = 0;
if (!strcmp(*parg,"-l")) {
popt = *parg++;
plib = *parg;
} else if (!strcmp(*parg,"--library")) {
popt = *parg++;
plib = *parg;
} else if (!strncmp(*parg,"-l",2)) {
popt = *parg;
plib = popt + 2;
} else if (!strncmp(*parg,"--library=",10)) {
popt = *parg;
plib = popt + 10;
}
if (plib)
if (fprintf(ectx->fdeps,"-l%s\n",plib) < 0)
return -1;
}
if (fflush(ectx->fdeps))
return -1;
return 0;
}
static int slbt_exec_link_create_archive(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
const char * arfilename,
bool fpic)
{
char ** aarg;
char ** parg;
char * ranlib[3];
char program[PATH_MAX];
char output [PATH_MAX];
/* initial state */
slbt_reset_arguments(ectx);
/* placeholders */
slbt_reset_placeholders(ectx);
/* alternate program (ar, ranlib) */
ectx->program = program;
/* output */
if ((size_t)snprintf(output,sizeof(output),"%s",
arfilename) >= sizeof(output))
return -1;
/* ar alternate argument vector */
if ((size_t)snprintf(program,sizeof(program),"%s",
dctx->cctx->host.ar) >= sizeof(program))
return -1;
aarg = ectx->altv;
*aarg++ = program;
*aarg++ = "cru";
*aarg++ = output;
/* input argument adjustment */
for (parg=ectx->cargv; *parg; parg++)
if (slbt_adjust_input_argument(*parg,".lo",".o",fpic))
*aarg++ = *parg;
*aarg = 0;
ectx->argv = ectx->altv;
/* step output */
if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT))
if (slbt_output_link(dctx,ectx))
return -1;
/* remove old archive as needed */
if (slbt_exec_link_remove_file(dctx,ectx,output))
return -1;
/* .deps */
if (slbt_exec_link_create_dep_file(ectx,ectx->cargv,arfilename))
return -1;
/* ar spawn */
if ((slbt_spawn(ectx,true) < 0) || ectx->exitcode)
return -1;
/* input objects associated with .la archives */
for (parg=ectx->cargv; *parg; parg++)
if (slbt_adjust_input_argument(*parg,".la",".a",fpic))
if (slbt_archive_import(dctx,ectx,output,*parg))
return -1;
/* ranlib argv */
if ((size_t)snprintf(program,sizeof(program),"%s",
dctx->cctx->host.ranlib) >= sizeof(program))
return -1;
ranlib[0] = program;
ranlib[1] = output;
ranlib[2] = 0;
ectx->argv = ranlib;
/* step output */
if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT))
if (slbt_output_link(dctx,ectx))
return -1;
/* ranlib spawn */
if ((slbt_spawn(ectx,true) < 0) || ectx->exitcode)
return -1;
return 0;
}
static int slbt_exec_link_create_library(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
const char * dsofilename)
{
char ** parg;
char cwd [PATH_MAX];
char output [PATH_MAX];
char soname [PATH_MAX];
struct slbt_deps_meta depsmeta = {0};
/* initial state */
slbt_reset_arguments(ectx);
/* placeholders */
slbt_reset_placeholders(ectx);
/* input argument adjustment */
for (parg=ectx->cargv; *parg; parg++)
slbt_adjust_input_argument(*parg,".lo",".o",true);
/* linker argument adjustment */
for (parg=ectx->cargv; *parg; parg++)
if (slbt_adjust_linker_argument(
*parg,true,
dctx->cctx->settings.dsosuffix,
dctx->cctx->settings.arsuffix,
&depsmeta) < 0)
return -1;
/* --no-undefined */
if (dctx->cctx->drvflags & SLBT_DRIVER_NO_UNDEFINED)
*ectx->noundef = "-Wl,--no-undefined";
/* -soname */
if (!(dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION)) {
if ((size_t)snprintf(soname,sizeof(soname),"-Wl,%s%s%s.%d",
dctx->cctx->settings.dsoprefix,
dctx->cctx->libname,
dctx->cctx->settings.dsosuffix,
dctx->cctx->verinfo.major)
>= sizeof(soname))
return -1;
*ectx->soname = "-Wl,-soname";
*ectx->lsoname = soname;
}
/* shared object */
*ectx->dpic = "-shared";
*ectx->fpic = "-fPIC";
/* output */
if (dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION) {
strcpy(output,dsofilename);
} else {
if ((size_t)snprintf(output,sizeof(output),"%s.%d.%d.%d",
dsofilename,
dctx->cctx->verinfo.major,
dctx->cctx->verinfo.minor,
dctx->cctx->verinfo.revision)
>= sizeof(output))
return -1;
}
*ectx->lout[0] = "-o";
*ectx->lout[1] = output;
/* cwd */
if (!getcwd(cwd,sizeof(cwd)))
return -1;
/* .libs/libfoo.so --> -L.libs -lfoo */
if (slbt_exec_link_adjust_argument_vector(
dctx,ectx,cwd,true))
return -1;
/* using alternate argument vector */
ectx->argv = ectx->altv;
ectx->program = ectx->altv[0];
/* step output */
if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT))
if (slbt_output_link(dctx,ectx))
return -1;
/* .deps */
if (slbt_exec_link_create_dep_file(ectx,ectx->argv,dsofilename))
return -1;
/* spawn */
if ((slbt_spawn(ectx,true) < 0) || ectx->exitcode)
return -1;
return 0;
}
static int slbt_exec_link_create_executable(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
const char * exefilename)
{
char ** parg;
char cwd [PATH_MAX];
char output [PATH_MAX];
char wrapper[PATH_MAX];
char wraplnk[PATH_MAX];
bool fabspath;
struct slbt_deps_meta depsmeta = {0};
/* initial state */
slbt_reset_arguments(ectx);
/* placeholders */
slbt_reset_placeholders(ectx);
/* input argument adjustment */
for (parg=ectx->cargv; *parg; parg++)
slbt_adjust_input_argument(*parg,".lo",".o",true);
/* linker argument adjustment */
for (parg=ectx->cargv; *parg; parg++)
if (slbt_adjust_linker_argument(
*parg,true,
dctx->cctx->settings.dsosuffix,
dctx->cctx->settings.arsuffix,
&depsmeta) < 0)
return -1;
/* --no-undefined */
if (dctx->cctx->drvflags & SLBT_DRIVER_NO_UNDEFINED)
*ectx->noundef = "-Wl,--no-undefined";
/* executable wrapper: header */
if ((size_t)snprintf(wrapper,sizeof(wrapper),"%s.wrapper.tmp",
dctx->cctx->output)
>= sizeof(wrapper))
return -1;
if (!(ectx->fwrapper = fopen(wrapper,"w")))
return -1;
if (fprintf(ectx->fwrapper,
"#!/bin/sh\n"
"# slibtool (pre-alpha): generated executable wrapper\n\n"
"if [ -z \"$%s\" ]; then\n"
"\tDL_PATH=\n"
"\tCOLON=\n"
"\tLCOLON=\n"
"else\n"
"\tDL_PATH=\n"
"\tCOLON=\n"
"\tLCOLON=':'\n"
"fi\n\n",
dctx->cctx->settings.ldpathenv) < 0)
return -1;
/* output */
if ((size_t)snprintf(output,sizeof(output),"%s",
exefilename)
>= sizeof(output))
return -1;
*ectx->lout[0] = "-o";
*ectx->lout[1] = output;
/* cwd */
if (!getcwd(cwd,sizeof(cwd)))
return -1;
/* .libs/libfoo.so --> -L.libs -lfoo */
if (slbt_exec_link_adjust_argument_vector(
dctx,ectx,cwd,false))
return -1;
/* using alternate argument vector */
ectx->argv = ectx->altv;
ectx->program = ectx->altv[0];
/* executable wrapper: footer */
fabspath = (exefilename[0] == '/');
if (fprintf(ectx->fwrapper,
"DL_PATH=\"$DL_PATH$LCOLON$%s\"\n\n"
"export %s=$DL_PATH\n\n"
"exec %s/%s \"$@\"\n",
dctx->cctx->settings.ldpathenv,
dctx->cctx->settings.ldpathenv,
fabspath ? "" : cwd,
fabspath ? &exefilename[1] : exefilename) < 0)
return -1;
/* step output */
if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT))
if (slbt_output_link(dctx,ectx))
return -1;
/* spawn */
if ((slbt_spawn(ectx,true) < 0) || ectx->exitcode)
return -1;
/* executable wrapper: finalize */
fclose(ectx->fwrapper);
ectx->fwrapper = 0;
if ((size_t)snprintf(wraplnk,sizeof(wraplnk),"%s.exe.wrapper",
dctx->cctx->output) >= sizeof(wraplnk))
return -1;
if (slbt_create_symlink(
dctx,ectx,
dctx->cctx->output,wraplnk,
false))
return -1;
if (rename(wrapper,dctx->cctx->output))
return -1;
if (chmod(dctx->cctx->output,0755))
return -1;
return 0;
}
static int slbt_exec_link_create_library_symlink(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
bool fmajor)
{
char target[PATH_MAX];
char lnkname[PATH_MAX];
sprintf(target,"%s.%d.%d.%d",
ectx->dsofilename,
dctx->cctx->verinfo.major,
dctx->cctx->verinfo.minor,
dctx->cctx->verinfo.revision);
if (fmajor)
sprintf(lnkname,"%s.%d",
ectx->dsofilename,
dctx->cctx->verinfo.major);
else
strcpy(lnkname,ectx->dsofilename);
return slbt_create_symlink(
dctx,ectx,
target,lnkname,
false);
}
int slbt_exec_link(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx)
{
int ret;
int fdlibs;
const char * output;
char * dot;
FILE * fout;
struct slbt_exec_ctx * actx;
/* context */
if (ectx)
actx = 0;
else if ((ret = slbt_get_exec_ctx(dctx,&ectx)))
return ret;
else
actx = ectx;
/* output suffix */
output = dctx->cctx->output;
dot = strrchr(output,'.');
/* .libs directory */
if (dctx->cctx->drvflags & SLBT_DRIVER_SHARED) {
if ((fdlibs = open(ectx->ldirname,O_DIRECTORY)) >= 0)
close(fdlibs);
else if ((errno != ENOENT) || mkdir(ectx->ldirname,0777)) {
slbt_free_exec_ctx(actx);
return -1;
}
}
/* non-pic libfoo.a */
if (dot && !strcmp(dot,".a"))
if (slbt_exec_link_create_archive(dctx,ectx,output,false)) {
slbt_free_exec_ctx(actx);
return -1;
}
/* pic libfoo.a */
if (dot && !strcmp(dot,".la"))
if (slbt_exec_link_create_archive(
dctx,ectx,
ectx->arfilename,
dctx->cctx->drvflags & SLBT_DRIVER_SHARED)) {
slbt_free_exec_ctx(actx);
return -1;
}
/* dynamic library */
if (dot && !strcmp(dot,".la") && dctx->cctx->rpath) {
/* linking: libfoo.so.x.y.z */
if (slbt_exec_link_create_library(
dctx,ectx,
ectx->dsofilename)) {
slbt_free_exec_ctx(actx);
return -1;
}
if (!(dctx->cctx->drvflags & SLBT_DRIVER_AVOID_VERSION)) {
/* symlink: libfoo.so.x --> libfoo.so.x.y.z */
if (slbt_exec_link_create_library_symlink(
dctx,ectx,
true)) {
slbt_free_exec_ctx(actx);
return -1;
}
/* symlink: libfoo.so --> libfoo.so.x.y.z */
if (slbt_exec_link_create_library_symlink(
dctx,ectx,
false)) {
slbt_free_exec_ctx(actx);
return -1;
}
}
}
/* executable */
if (!dctx->cctx->rpath && !dctx->cctx->libname) {
/* linking: .libs/exefilename */
if (slbt_exec_link_create_executable(
dctx,ectx,
ectx->exefilename)) {
slbt_free_exec_ctx(actx);
return -1;
}
}
/* no wrapper? */
if (!dot || strcmp(dot,".la")) {
slbt_free_exec_ctx(actx);
return 0;
}
/* hey, yo, let's rap it up */
if (!(fout = fopen(output,"w"))) {
slbt_free_exec_ctx(actx);
return -1;
}
/* wrapper symlink */
if (slbt_create_symlink(
dctx,ectx,
output,
ectx->lafilename,
true))
ret = -1;
else
ret = fprintf(fout,
"# slibtool (pre-alpha) generated file\n\n");
/* all done */
fclose(fout);
slbt_free_exec_ctx(actx);
return (ret > 0) ? 0 : -1;
}
|