Commit e467450 1 parent e82dae7 commit e467450 Copy full SHA for e467450
File tree 6 files changed +27
-5
lines changed
6 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,14 @@ include config.mk
2
2
3
3
# ### Populate [C|LD]FLAGS ####
4
4
COMMON_CFLAGS := $(CUSTOM_CFLAGS ) $(CFLAGS ) -Wall -D_GNU_SOURCE
5
- COMMON_LDFLAGS := $(CUSTOM_LDFLAGS ) $(LDFLAGS ) -T minieap_init_func.lds
5
+ COMMON_LDFLAGS := $(CUSTOM_LDFLAGS ) $(LDFLAGS )
6
6
LIBS += $(CUSTOM_LIBS )
7
7
8
+ # You are not cross-compiling for macOS on Linux, I guess?
9
+ ifeq ($(shell uname -s) ,Linux)
10
+ COMMON_LDFLAGS += -T minieap_init_func.lds
11
+ endif
12
+
8
13
ifeq ($(ENABLE_ICONV ) ,true)
9
14
COMMON_CFLAGS += -DENABLE_ICONV
10
15
ifeq ($(LIBICONV_STANDALONE ) ,true)
Original file line number Diff line number Diff line change @@ -11,8 +11,13 @@ IF_IMPL* sockraw_new();
11
11
IF_IMPL * libpcap_new ();
12
12
13
13
int init_if_impl_list () {
14
+ #ifdef __linux__
14
15
extern IF_IMPL * (* __IF_IMPL_LIST_START__ )();
15
16
extern IF_IMPL * (* __IF_IMPL_LIST_END__ )(); // They are just location markers, do not care about their content
17
+ #else
18
+ extern IF_IMPL * (* __IF_IMPL_LIST_START__ )() __asm("section$start$__DATA$__ifimplinit" );
19
+ extern IF_IMPL * (* __IF_IMPL_LIST_END__ )() __asm("section$end$__DATA$__ifimplinit" );
20
+ #endif
16
21
IF_IMPL * (* * func )();
17
22
int i = 0 ;
18
23
for (func = & __IF_IMPL_LIST_START__ ; func < & __IF_IMPL_LIST_END__ ; ++ i , ++ func ) {
Original file line number Diff line number Diff line change 20
20
21
21
#define FRAME_BUF_SIZE 1512
22
22
23
+ #ifdef __linux__
23
24
#define IF_IMPL_INIT (func ) __define_in_init(func, ".ifimplinit")
25
+ #else
26
+ #define IF_IMPL_INIT (func ) __define_in_init(func, "__DATA,__ifimplinit")
27
+ #endif
24
28
25
29
/*
26
30
* Representing an interface driver plugin.
Original file line number Diff line number Diff line change 2
2
#define _MINIEAP_MODULE_INIT
3
3
4
4
#define __define_in_init (func , sect ) \
5
- static void* __init_##func __attribute__((unused, __section__(sect))) = func;
6
-
5
+ static void* __init_##func __attribute__((used, __section__(sect))) = func;
7
6
#endif
Original file line number Diff line number Diff line change 5
5
#include "eth_frame.h"
6
6
#include "module_init.h"
7
7
8
+ #ifdef __linux__
8
9
#define PACKET_PLUGIN_INIT (func ) __define_in_init(func, ".pktplugininit")
10
+ #else
11
+ #define PACKET_PLUGIN_INIT (func ) __define_in_init(func, "__DATA,__pktplugininit")
12
+ #endif
9
13
10
14
typedef struct _packet_plugin {
11
15
/*
Original file line number Diff line number Diff line change @@ -18,8 +18,13 @@ PACKET_PLUGIN* packet_plugin_rjv3_new();
18
18
PACKET_PLUGIN * packet_plugin_printer_new ();
19
19
20
20
int init_packet_plugin_list () {
21
- extern PACKET_PLUGIN * (* __PACKET_PLUGIN_LIST_START__ )(void );
22
- extern PACKET_PLUGIN * (* __PACKET_PLUGIN_LIST_END__ )(void );
21
+ #ifdef __linux__
22
+ extern PACKET_PLUGIN * (* __PACKET_PLUGIN_LIST_START__ )();
23
+ extern PACKET_PLUGIN * (* __PACKET_PLUGIN_LIST_END__ )();
24
+ #else
25
+ extern PACKET_PLUGIN * (* __PACKET_PLUGIN_LIST_START__ )() __asm("section$start$__DATA$__pktplugininit" );
26
+ extern PACKET_PLUGIN * (* __PACKET_PLUGIN_LIST_END__ )() __asm("section$end$__DATA$__pktplugininit" );
27
+ #endif
23
28
PACKET_PLUGIN * (* * func )();
24
29
int i = 0 ;
25
30
for (func = & __PACKET_PLUGIN_LIST_START__ ; func < & __PACKET_PLUGIN_LIST_END__ ; ++ i , ++ func ) {
You can’t perform that action at this time.
0 commit comments