ObjFW  Check-in [45a8b2333d]

Overview
Comment:Add __(de)register_frame_info to amiga-library.m

This way the runtime's linklib will use the ones passed to the ObjFW
.library.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | amiga-library
Files: files | file ages | folders
SHA3-256: 45a8b2333d526f2a07740cb3fd819b677882a7190176ec2de66f80234f06b515
User & Date: js on 2020-06-07 16:53:31
Other Links: branch diff | manifest | tags
Context
2020-06-07
18:27
Add _Unwind_Backtrace to amiga-library.m check-in: b50dc283cf user: js tags: amiga-library
16:53
Add __(de)register_frame_info to amiga-library.m check-in: 45a8b2333d user: js tags: amiga-library
16:34
Pass __sF around instead of std* individually check-in: 514944f1ea user: js tags: amiga-library
Changes

Modified src/amiga-library.h from [5676e5d650] to [2c7d9984f0].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "macros.h"

#if defined(OF_COMPILING_AMIGA_LIBRARY) || defined(OF_COMPILING_AMIGA_LINKLIB)
# if defined(__MORPHOS__)
#  include <ppcinline/macros.h>
#  define OF_M68K_ARG(type, name, reg) type name = (type)REG_##reg;
# else
#  define OF_M68K_ARG(type, name, reg)		\
	register type reg_##name __asm__(#reg);	\
	type name = reg_##name;
# endif







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "macros.h"

#if defined(OF_COMPILING_AMIGA_LIBRARY) || defined(OF_COMPILING_AMIGA_LINKLIB)
# ifdef OF_MORPHOS
#  include <ppcinline/macros.h>
#  define OF_M68K_ARG(type, name, reg) type name = (type)REG_##reg;
# else
#  define OF_M68K_ARG(type, name, reg)		\
	register type reg_##name __asm__(#reg);	\
	type name = reg_##name;
# endif
56
57
58
59
60
61
62

63
64
65
66

67
68
69
70
71
72
73
74
75
76
	void (*_Nonnull _Unwind_SetIP)(void *_Nonnull, uintptr_t);
	void (*_Nonnull _Unwind_SetGR)(void *_Nonnull, int, uintptr_t);
# ifdef HAVE_SJLJ_EXCEPTIONS
	void (*_Nonnull _Unwind_SjLj_Resume)(void *_Nonnull);
# else
	void (*_Nonnull _Unwind_Resume)(void *_Nonnull);
# endif

	void (*_Nonnull __register_frame_info)(const void *_Nonnull,
	    void *_Nonnull);
	void *_Nullable (*_Nonnull __deregister_frame_info)(
	    const void *_Nonnull);


	/* Needed only by ObjFW. */
	int (*_Nonnull vsnprintf)(const char *_Nonnull restrict, size_t,
	    const char *_Nonnull restrict, va_list);
	void (*_Nonnull exit)(int);
	char *_Nullable (*_Nonnull setlocale)(int, const char *_Nullable);
};

extern bool of_init(unsigned int version, struct of_libc *libc, FILE **sF);
#endif







>




>










56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
	void (*_Nonnull _Unwind_SetIP)(void *_Nonnull, uintptr_t);
	void (*_Nonnull _Unwind_SetGR)(void *_Nonnull, int, uintptr_t);
# ifdef HAVE_SJLJ_EXCEPTIONS
	void (*_Nonnull _Unwind_SjLj_Resume)(void *_Nonnull);
# else
	void (*_Nonnull _Unwind_Resume)(void *_Nonnull);
# endif
# ifdef OF_AMIGAOS_M68K
	void (*_Nonnull __register_frame_info)(const void *_Nonnull,
	    void *_Nonnull);
	void *_Nullable (*_Nonnull __deregister_frame_info)(
	    const void *_Nonnull);
# endif

	/* Needed only by ObjFW. */
	int (*_Nonnull vsnprintf)(const char *_Nonnull restrict, size_t,
	    const char *_Nonnull restrict, va_list);
	void (*_Nonnull exit)(int);
	char *_Nullable (*_Nonnull setlocale)(int, const char *_Nullable);
};

extern bool of_init(unsigned int version, struct of_libc *libc, FILE **sF);
#endif

Modified src/amiga-library.m from [1f4ef323c1] to [5d844627f0].

56
57
58
59
60
61
62


63
64
65
66
67
68
69
	bool initialized;
};

#ifdef OF_AMIGAOS_M68K
extern uintptr_t __CTOR_LIST__[];
extern const void *_EH_FRAME_BEGINS__;
extern void *_EH_FRAME_OBJECTS__;


#endif

extern bool glue_of_init(void);

#ifdef OF_AMIGAOS_M68K
void
__init_eh(void)







>
>







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
	bool initialized;
};

#ifdef OF_AMIGAOS_M68K
extern uintptr_t __CTOR_LIST__[];
extern const void *_EH_FRAME_BEGINS__;
extern void *_EH_FRAME_OBJECTS__;
extern void __register_frame_info(const void *, void *);
extern void *__deregister_frame_info(const void *);
#endif

extern bool glue_of_init(void);

#ifdef OF_AMIGAOS_M68K
void
__init_eh(void)
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299

	if (base->parent != NULL) {
		struct ObjFWBase *parent;

#ifdef OF_AMIGAOS_M68K
		if (base->initialized)
			for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
				libc.__deregister_frame_info(
				    (&_EH_FRAME_BEGINS__)[i]);
#endif

		parent = base->parent;

		FreeMem(base->dataSeg - DATA_OFFSET, getDataSize());
		FreeMem((char *)base - base->library.lib_NegSize,







|







287
288
289
290
291
292
293
294
295
296
297
298
299
300
301

	if (base->parent != NULL) {
		struct ObjFWBase *parent;

#ifdef OF_AMIGAOS_M68K
		if (base->initialized)
			for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
				__deregister_frame_info(
				    (&_EH_FRAME_BEGINS__)[i]);
#endif

		parent = base->parent;

		FreeMem(base->dataSeg - DATA_OFFSET, getDataSize());
		FreeMem((char *)base - base->library.lib_NegSize,
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
	__sF = sF;

#ifdef OF_AMIGAOS_M68K
	if ((size_t)_EH_FRAME_BEGINS__ != (size_t)_EH_FRAME_OBJECTS__)
		return false;

	for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
		libc.__register_frame_info((&_EH_FRAME_BEGINS__)[i],
		    (&_EH_FRAME_OBJECTS__)[i]);

	iter0 = &__CTOR_LIST__[1];
#elif defined(OF_MORPHOS)
	__asm__ (
	    "lis	%0, ctors+4@ha\n\t"
	    "la		%0, ctors+4@l(%0)\n\t"







|







338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
	__sF = sF;

#ifdef OF_AMIGAOS_M68K
	if ((size_t)_EH_FRAME_BEGINS__ != (size_t)_EH_FRAME_OBJECTS__)
		return false;

	for (size_t i = 1; i <= (size_t)_EH_FRAME_BEGINS__; i++)
		__register_frame_info((&_EH_FRAME_BEGINS__)[i],
		    (&_EH_FRAME_OBJECTS__)[i]);

	iter0 = &__CTOR_LIST__[1];
#elif defined(OF_MORPHOS)
	__asm__ (
	    "lis	%0, ctors+4@ha\n\t"
	    "la		%0, ctors+4@l(%0)\n\t"
396
397
398
399
400
401
402






403
404
405
406
407
408
409

	va_start(args, fmt);
	ret = libc.vfprintf(stream, fmt, args);
	va_end(args);

	return ret;
}







int
fflush(FILE *restrict stream)
{
	return libc.fflush(stream);
}








>
>
>
>
>
>







398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417

	va_start(args, fmt);
	ret = libc.vfprintf(stream, fmt, args);
	va_end(args);

	return ret;
}

int
vfprintf(FILE *restrict stream, const char *restrict fmt, va_list args)
{
	return libc.vfprintf(stream, fmt, args);
}

int
fflush(FILE *restrict stream)
{
	return libc.fflush(stream);
}

492
493
494
495
496
497
498














499
500
501
502
503
504
505
#else
void
_Unwind_Resume(void *ex)
{
	libc._Unwind_Resume(ex);
}
#endif















int
vsnprintf(char *restrict str, size_t size, const char *restrict fmt,
    va_list args)
{
	return libc.vsnprintf(str, size, fmt, args);
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
#else
void
_Unwind_Resume(void *ex)
{
	libc._Unwind_Resume(ex);
}
#endif

#ifdef OF_AMIGAOS_M68K
void
__register_frame_info(const void *begin, void *object)
{
	libc.__register_frame_info(begin, object);
}

void
*__deregister_frame_info(const void *begin)
{
	return libc.__deregister_frame_info(begin);
}
#endif

int
vsnprintf(char *restrict str, size_t size, const char *restrict fmt,
    va_list args)
{
	return libc.vsnprintf(str, size, fmt, args);
}

Modified src/runtime/linklib/linklib.m from [67c7f14c6b] to [4b66b4aaff].

53
54
55
56
57
58
59

60
61

62
63
64
65
66
67
68
extern void _Unwind_SetIP(void *, uintptr_t);
extern void _Unwind_SetGR(void *, int, uintptr_t);
#ifdef HAVE_SJLJ_EXCEPTIONS
extern void _Unwind_SjLj_Resume(void *);
#else
extern void _Unwind_Resume(void *);
#endif

extern void __register_frame_info(const void *, void *);
extern void *__deregister_frame_info(const void *);


struct Library *ObjFWRTBase;
void *__objc_class_name_Protocol;

static void __attribute__((__used__))
ctor(void)
{







>


>







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
extern void _Unwind_SetIP(void *, uintptr_t);
extern void _Unwind_SetGR(void *, int, uintptr_t);
#ifdef HAVE_SJLJ_EXCEPTIONS
extern void _Unwind_SjLj_Resume(void *);
#else
extern void _Unwind_Resume(void *);
#endif
#ifdef OF_AMIGAOS_M68K
extern void __register_frame_info(const void *, void *);
extern void *__deregister_frame_info(const void *);
#endif

struct Library *ObjFWRTBase;
void *__objc_class_name_Protocol;

static void __attribute__((__used__))
ctor(void)
{
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
		._Unwind_SetIP = _Unwind_SetIP,
		._Unwind_SetGR = _Unwind_SetGR,
#ifdef HAVE_SJLJ_EXCEPTIONS
		._Unwind_SjLj_Resume = _Unwind_SjLj_Resume,
#else
		._Unwind_Resume = _Unwind_Resume,
#endif

		.__register_frame_info = __register_frame_info,
		.__deregister_frame_info = __deregister_frame_info,

	};

	if (initialized)
		return;

	if ((ObjFWRTBase = OpenLibrary(OBJFWRT_AMIGA_LIB,
	    OBJFWRT_LIB_MINOR)) == NULL) {
		fputs("Failed to open " OBJFWRT_AMIGA_LIB "!\n", stderr);
		abort();
	}

	if (!glue_objc_init(1, &libc, __sF)) {

		fputs("Failed to initialize " OBJFWRT_AMIGA_LIB "!\n", stderr);
		abort();
	}

	initialized = true;
}

static void __attribute__((__used__))







>


>







|




>
|







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
		._Unwind_SetIP = _Unwind_SetIP,
		._Unwind_SetGR = _Unwind_SetGR,
#ifdef HAVE_SJLJ_EXCEPTIONS
		._Unwind_SjLj_Resume = _Unwind_SjLj_Resume,
#else
		._Unwind_Resume = _Unwind_Resume,
#endif
#ifdef OF_AMIGAOS_M68K
		.__register_frame_info = __register_frame_info,
		.__deregister_frame_info = __deregister_frame_info,
#endif
	};

	if (initialized)
		return;

	if ((ObjFWRTBase = OpenLibrary(OBJFWRT_AMIGA_LIB,
	    OBJFWRT_LIB_MINOR)) == NULL) {
		fprintf(stderr, "Failed to open %s!\n", OBJFWRT_AMIGA_LIB);
		abort();
	}

	if (!glue_objc_init(1, &libc, __sF)) {
		fprintf(stderr, "Failed to initialize %s!\n",
		    OBJFWRT_AMIGA_LIB);
		abort();
	}

	initialized = true;
}

static void __attribute__((__used__))

Modified src/runtime/private.h from [5d82a9b9bc] to [6a201be4b3].

245
246
247
248
249
250
251

252
253
254
255

256
257
258
259
260
261
262
263
264
265
266
267
	void (*_Nonnull _Unwind_SetIP)(void *_Nonnull, uintptr_t);
	void (*_Nonnull _Unwind_SetGR)(void *_Nonnull, int, uintptr_t);
# ifdef HAVE_SJLJ_EXCEPTIONS
	void (*_Nonnull _Unwind_SjLj_Resume)(void *_Nonnull);
# else
	void (*_Nonnull _Unwind_Resume)(void *_Nonnull);
# endif

	void (*_Nonnull __register_frame_info)(const void *_Nonnull,
	    void *_Nonnull);
	void *_Nullable (*_Nonnull __deregister_frame_info)(
	    const void *_Nonnull);

};
#endif

#ifdef OBJC_COMPILING_AMIGA_LIBRARY
# if defined(__MORPHOS__)
#  include <ppcinline/macros.h>
#  define OBJC_M68K_ARG(type, name, reg) type name = (type)REG_##reg;
# else
#  define OBJC_M68K_ARG(type, name, reg)	\
	register type reg_##name __asm__(#reg);	\
	type name = reg_##name;
# endif







>




>




|







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
	void (*_Nonnull _Unwind_SetIP)(void *_Nonnull, uintptr_t);
	void (*_Nonnull _Unwind_SetGR)(void *_Nonnull, int, uintptr_t);
# ifdef HAVE_SJLJ_EXCEPTIONS
	void (*_Nonnull _Unwind_SjLj_Resume)(void *_Nonnull);
# else
	void (*_Nonnull _Unwind_Resume)(void *_Nonnull);
# endif
# if defined(__amigaos__) && !defined(__MORPHOS__)
	void (*_Nonnull __register_frame_info)(const void *_Nonnull,
	    void *_Nonnull);
	void *_Nullable (*_Nonnull __deregister_frame_info)(
	    const void *_Nonnull);
# endif
};
#endif

#ifdef OBJC_COMPILING_AMIGA_LIBRARY
# ifdef __MORPHOS__
#  include <ppcinline/macros.h>
#  define OBJC_M68K_ARG(type, name, reg) type name = (type)REG_##reg;
# else
#  define OBJC_M68K_ARG(type, name, reg)	\
	register type reg_##name __asm__(#reg);	\
	type name = reg_##name;
# endif