Skip to content

Instantly share code, notes, and snippets.

View rui314's full-sized avatar

Rui Ueyama rui314

  • Blue Whale Systems
  • Tokyo
View GitHub Profile
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();
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)
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 October 13, 2013 07:42
A nqueen solver that works on my lisp implemenation (https://github.com/rui314/minilisp)
(defun list (expr . rest)
(cons expr rest))
(defun zero? (expr)
(= expr 0))
(defun nil? (expr)
(eq expr ()))
(defmacro let1 (var val . body)
@rui314
rui314 / gist:2018964
Created March 12, 2012 00:51
N queen
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");
}
@rui314
rui314 / gist:2014832
Created March 11, 2012 03:16
N queen
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(". ");
}
}