Support for gcc -m32 option

This commit is contained in:
KenjiroIchise 2020-01-02 18:56:49 +09:00
parent bf3be7f03d
commit e5785a1729
6 changed files with 75 additions and 68 deletions

View file

@ -44,7 +44,7 @@
#include <signal.h>
#ifndef __x86_64__
#include <asm/signal.h>
//#include <asm/signal.h>
#endif
@ -60,7 +60,7 @@
#ifndef __x86_64__
#include <linux/elf.h>
#include <linux/uio.h>
//#include <linux/uio.h>
#endif

View file

@ -27,7 +27,7 @@
#ifdef __i386__
typedef struct pt_regs CONTEXT_REGS;
typedef struct user_regs_struct CONTEXT_REGS;
#endif
#ifdef __x86_64__

View file

@ -0,0 +1,35 @@
COMPILER = gcc
CFLAGS = -m32 -fPIC -g -MMD -MP -Wall -Wextra -Winit-self -Wno-missing-field-initializers -Doff64_t=__off64_t
ifeq "$(shell getconf LONG_BIT)" "64"
LDFLAGS = -l:libz.so.1 -ldl -pthread -lm -shared
else
LDFLAGS = -l:libz.so.1 -ldl -pthread -lm -shared
endif
LIBS =
INCLUDE = -I./include
TARGET = ./bin/libceserver-extension_x86.so
SRCDIR = ./source
ifeq "$(strip $(SRCDIR))" ""
SRCDIR = .
endif
SOURCES = $(wildcard $(SRCDIR)/*.c)
OBJDIR = ./obj
ifeq "$(strip $(OBJDIR))" ""
OBJDIR = .
endif
OBJECTS = $(addprefix $(OBJDIR)/, $(notdir $(SOURCES:.c=.o)))
DEPENDS = $(OBJECTS:.o=.d)
$(TARGET): $(OBJECTS) $(LIBS)
$(COMPILER) -m32 -o $@ $^ $(LDFLAGS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
-mkdir -p $(OBJDIR)
$(COMPILER) $(CFLAGS) $(INCLUDE) -o $@ -c $<
all: clean $(TARGET)
clean:
-rm -f $(OBJECTS) $(DEPENDS) $(TARGET)
-include $(DEPENDS)

View file

@ -382,8 +382,8 @@ printf("After wait 2. PID=%d\n", pid);
//save the current state and set the state to what I need it to be
#ifdef __i386__
struct pt_regs origregs;
struct pt_regs newregs;
struct user_regs_struct origregs;
struct user_regs_struct newregs;
#endif
#ifdef __x86_64__

View file

@ -0,0 +1,35 @@
COMPILER = gcc
CFLAGS = -m32 -g -MMD -MP -Wall -Wextra -Winit-self -Wno-missing-field-initializers -Doff64_t=__off64_t
ifeq "$(shell getconf LONG_BIT)" "64"
LDFLAGS = -l:libz.so.1 -ldl -pthread
else
LDFLAGS = -l:libz.so.1 -ldl -pthread
endif
LIBS =
INCLUDE = -I./include
TARGET = ./bin/ceserver
SRCDIR = ./source
ifeq "$(strip $(SRCDIR))" ""
SRCDIR = .
endif
SOURCES = $(wildcard $(SRCDIR)/*.c)
OBJDIR = ./obj
ifeq "$(strip $(OBJDIR))" ""
OBJDIR = .
endif
OBJECTS = $(addprefix $(OBJDIR)/, $(notdir $(SOURCES:.c=.o)))
DEPENDS = $(OBJECTS:.o=.d)
$(TARGET): $(OBJECTS) $(LIBS)
$(COMPILER) -m32 -o $@ $^ $(LDFLAGS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
-mkdir -p $(OBJDIR)
$(COMPILER) $(CFLAGS) $(INCLUDE) -o $@ -c $<
all: clean $(TARGET)
clean:
-rm -f $(OBJECTS) $(DEPENDS) $(TARGET)
-include $(DEPENDS)

View file

@ -1,66 +1,3 @@
#include <stdio.h>
#include <pthread.h>
#include <sys/mman.h>
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdint.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <strings.h>
#include <sys/mman.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <sys/syscall.h>
#include <signal.h>
#ifndef __x86_64__
#include <asm/signal.h>
#endif
#include <sys/eventfd.h>
#include <errno.h>
#include <semaphore.h>
#include <sys/queue.h>
#include <limits.h>
#include <sys/ptrace.h>
#ifndef __x86_64__
#include <linux/elf.h>
#include <linux/uio.h>
#endif
#ifdef __arm__
#ifndef __ANDROID__
#include <linux/user.h>
#endif
#endif
#ifndef __ANDROID__
#if defined(__i386__) || defined(__x86_64__)
#include <sys/user.h>
#endif
#endif
#include "api.h"
#include "porthelp.h"
#include "ceserver.h"