Make some quick fixes and cleanup

This commit is contained in:
Justine Tunney 2022-06-26 02:58:36 -07:00
parent fa5c2a24b5
commit 61257d48d4
63 changed files with 275 additions and 257 deletions

View file

@ -1653,7 +1653,8 @@ static int SymbolType(struct As *a, struct Slice s) {
}
}
static int GrabSection(struct As *a, int name, int flags, int type) {
static int GrabSection(struct As *a, int name, int flags, int type, int group,
int comdat) {
int i;
for (i = 0; i < a->sections.n; ++i) {
if (!strcmp(a->strings.p[name], a->strings.p[a->sections.p[i].name])) {
@ -1664,7 +1665,7 @@ static int GrabSection(struct As *a, int name, int flags, int type) {
}
static void OnSection(struct As *a, struct Slice s) {
int name, flags, type;
int name, flags, type, group = -1, comdat = -1;
name = SliceDup(a, GetSlice(a));
if (startswith(a->strings.p[name], ".text")) {
flags = SHF_ALLOC | SHF_EXECINSTR;
@ -1685,9 +1686,17 @@ static void OnSection(struct As *a, struct Slice s) {
if (IsComma(a)) {
++a->i;
type = SectionType(a, GetSlice(a));
if (IsComma(a)) {
++a->i;
group = SectionType(a, GetSlice(a));
if (IsComma(a)) {
++a->i;
comdat = SectionType(a, GetSlice(a));
}
}
}
}
SetSection(a, GrabSection(a, name, flags, type));
SetSection(a, GrabSection(a, name, flags, type, group, comdat));
}
static void OnPushsection(struct As *a, struct Slice s) {
@ -1705,7 +1714,7 @@ static void OnIdent(struct As *a, struct Slice s) {
struct Slice arg;
int comment, oldsection;
comment = GrabSection(a, StrDup(a, ".comment"), SHF_MERGE | SHF_STRINGS,
SHT_PROGBITS);
SHT_PROGBITS, -1, -1);
oldsection = a->section;
a->section = comment;
arg = GetSlice(a);

View file

@ -10,7 +10,7 @@ int __gdtoa_unlock(void);
int __gdtoa_lock1(void);
int __gdtoa_unlock1(void);
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
#ifdef _NOPL0
#define __gdtoa_lock() _NOPL0("__threadcalls", __gdtoa_lock)
#define __gdtoa_unlock() _NOPL0("__threadcalls", __gdtoa_unlock)
#define __gdtoa_lock1() _NOPL0("__threadcalls", __gdtoa_lock1)

View file

@ -144,7 +144,7 @@
/*
** Macro to disable warnings about missing "break" at the end of a "case".
*/
#if GCC_VERSION>=7000000
#if GCC_VERSION>=7000000 && !defined(__chibicc__)
# define deliberate_fall_through __attribute__((fallthrough));
#else
# define deliberate_fall_through