Skip to content

Instantly share code, notes, and snippets.

View gist:2ba27dbb8766a4f16fcb
diff --git a/ELF/OutputSections.cpp b/ELF/OutputSections.cpp
index c941993..cefdb46 100644
--- a/ELF/OutputSections.cpp
+++ b/ELF/OutputSections.cpp
@@ -844,8 +844,8 @@ static bool compCtors(const InputSection<ELFT> *A,
assert(Y.startswith(".ctors") || Y.startswith(".dtors"));
X = X.substr(6);
Y = Y.substr(6);
- if (X.empty() || Y.empty())
- return X.empty();
View gist:283099fd4e5214264d9e
diff --git a/ELF/OutputSections.cpp b/ELF/OutputSections.cpp
index b885601..1a6fbc1 100644
--- a/ELF/OutputSections.cpp
+++ b/ELF/OutputSections.cpp
@@ -1385,18 +1385,22 @@ StringTableSection<ELFT>::StringTableSection(StringRef Name, bool Dynamic)
// we obtained in the former function can be written in the latter.
// This design eliminated that need.
template <class ELFT> void StringTableSection<ELFT>::reserve(StringRef S) {
- Reserved += S.size() + 1; // +1 for NUL
+ if (Seen.insert(S).second)
View gist:2a3b97720812aff656ab
diff --git a/src/util.cc b/src/util.cc
index 746d7ed..3a3c7df 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -190,6 +190,9 @@ bool CanonicalizePath(char* path, size_t* len, unsigned int* slash_bits,
bits_offset--;
bits = ShiftOverBit(bits_offset, bits);
#endif
+ } else if (*start == '/') {
+ src += 3;
@rui314
rui314 / gist:6959261
Created Oct 13, 2013
A nqueen solver that works on my lisp implemenation (https://github.com/rui314/minilisp)
View gist:6959261
(defun list (expr . rest)
(cons expr rest))
(defun zero? (expr)
(= expr 0))
(defun nil? (expr)
(eq expr ()))
(defmacro let1 (var val . body)
View gist:2018964
int print_board(int board[][8]) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (board[i][j])
printf("Q ");
else
printf(". ");
}
printf("\n");
}
View gist:2014832
int print_board(int *board) {
for (int i = 0; i < 8; i = i + 1) {
for (int j = 0; j < 8; j =j +1) {
int *v = board + i * 8 + j;
if (*v) {
printf("Q ");
} else {
printf(". ");
}
}