From jakub@redhat.com Fri Jan 2 17:15:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 02 Jan 2004 17:15:00 -0000 Subject: [PATCH] Put regexec.c's re_string_t into re_match_context_t Message-ID: <20040102150845.GJ2020@sunsite.ms.mff.cuni.cz> Hi! This patch on top of http://sources.redhat.com/ml/libc-alpha/2004-01/msg00019.html (though it should apply on top of http://sources.redhat.com/ml/libc-alpha/2004-01/msg00011.html as well) moves re_search_internal's input into mctx object. Both objects live for the same time (till re_search_internal exits) and there is no need to jump between them using pointers. 2004-01-02 Jakub Jelinek * posix/regex_internal.h (re_match_context_t): Make input re_string_t instead of a pointer to it. * posix/regex_internal.c (re_string_construct_common): Don't clear pstr here... (re_string_construct): ... but only here. * posix/regexec.c (match_ctx_init): Remove input argument. Don't initialize fields to zero. (re_search_internal): Move input into mctx.input. (acquire_init_state_context, check_matching, check_halt_state_context, proceed_next_node, clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb, transit_state, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, check_arrival, check_arrival_add_next_nodes, check_node_accept, extend_buffers): Change mctx->input into &mctx->input and mctx->input->field into mctx->input.field. --- libc/posix/regex_internal.h.jj 2004-01-02 15:42:54.000000000 +0100 +++ libc/posix/regex_internal.h 2004-01-02 15:44:09.000000000 +0100 @@ -547,13 +547,13 @@ struct re_backref_cache_entry typedef struct { + /* The string object corresponding to the input string. */ + re_string_t input; /* EFLAGS of the argument of regexec. */ int eflags; /* Where the matching ends. */ int match_last; int last_node; - /* The string object corresponding to the input string. */ - re_string_t *input; /* The state log used by the matcher. */ re_dfastate_t **state_log; int state_log_top; --- libc/posix/regex_internal.c.jj 2004-01-02 16:07:25.000000000 +0100 +++ libc/posix/regex_internal.c 2004-01-02 15:55:34.000000000 +0100 @@ -86,6 +86,7 @@ re_string_construct (pstr, str, len, tra const re_dfa_t *dfa; { reg_errcode_t ret; + memset (pstr, '\0', sizeof (re_string_t)); re_string_construct_common (str, len, pstr, trans, icase, dfa); if (len > 0) @@ -185,7 +186,6 @@ re_string_construct_common (str, len, ps int icase; const re_dfa_t *dfa; { - memset (pstr, '\0', sizeof (re_string_t)); pstr->raw_mbs = (const unsigned char *) str; pstr->len = len; pstr->raw_len = len; --- libc/posix/regexec.c.jj 2004-01-02 15:42:48.000000000 +0100 +++ libc/posix/regexec.c 2004-01-02 15:54:08.000000000 +0100 @@ -19,7 +19,7 @@ 02111-1307 USA. */ static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, - re_string_t *input, int n) internal_function; + int n) internal_function; static void match_ctx_clean (re_match_context_t *mctx) internal_function; static void match_ctx_free (re_match_context_t *cache) internal_function; static void match_ctx_free_subtops (re_match_context_t *mctx) internal_function; @@ -572,7 +572,6 @@ re_search_internal (preg, string, length { reg_errcode_t err; re_dfa_t *dfa = (re_dfa_t *)preg->buffer; - re_string_t input; int left_lim, right_lim, incr; int fl_longest_match, match_first, match_last = -1; int fast_translate, sb; @@ -610,15 +609,15 @@ re_search_internal (preg, string, length /* We must check the longest matching, if nmatch > 0. */ fl_longest_match = (nmatch != 0 || dfa->nbackref); - err = re_string_allocate (&input, string, length, dfa->nodes_len + 1, + err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, preg->translate, preg->syntax & RE_ICASE, dfa); if (BE (err != REG_NOERROR, 0)) goto free_return; - input.stop = stop; - input.raw_stop = stop; - input.newline_anchor = preg->newline_anchor; + mctx.input.stop = stop; + mctx.input.raw_stop = stop; + mctx.input.newline_anchor = preg->newline_anchor; - err = match_ctx_init (&mctx, eflags, &input, dfa->nbackref * 2); + err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2); if (BE (err != REG_NOERROR, 0)) goto free_return; @@ -628,7 +627,7 @@ re_search_internal (preg, string, length multi character collating element. */ if (nmatch > 1 || dfa->has_mb_node) { - mctx.state_log = re_malloc (re_dfastate_t *, input.bufs_len + 1); + mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1); if (BE (mctx.state_log == NULL, 0)) { err = REG_ESPACE; @@ -639,8 +638,8 @@ re_search_internal (preg, string, length mctx.state_log = NULL; match_first = start; - input.tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF - : CONTEXT_NEWLINE | CONTEXT_BEGBUF); + mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF + : CONTEXT_NEWLINE | CONTEXT_BEGBUF; /* Check incrementally whether of not the input string match. */ incr = (range < 0) ? -1 : 1; @@ -706,18 +705,18 @@ re_search_internal (preg, string, length instead. */ /* If MATCH_FIRST is out of the valid range, reconstruct the buffers. */ - if (input.raw_mbs_idx + input.valid_raw_len <= match_first - || match_first < input.raw_mbs_idx) + if (mctx.input.raw_mbs_idx + mctx.input.valid_raw_len <= match_first + || match_first < mctx.input.raw_mbs_idx) { - err = re_string_reconstruct (&input, match_first, eflags); + err = re_string_reconstruct (&mctx.input, match_first, eflags); if (BE (err != REG_NOERROR, 0)) goto free_return; } /* If MATCH_FIRST is out of the buffer, leave it as '\0'. Note that MATCH_FIRST must not be smaller than 0. */ ch = ((match_first >= length) ? 0 - : re_string_byte_at (&input, - match_first - input.raw_mbs_idx)); + : re_string_byte_at (&mctx.input, + match_first - mctx.input.raw_mbs_idx)); if (fastmap[ch]) break; match_first += incr; @@ -730,13 +729,13 @@ re_search_internal (preg, string, length /* Reconstruct the buffers so that the matcher can assume that the matching starts from the beginning of the buffer. */ - err = re_string_reconstruct (&input, match_first, eflags); + err = re_string_reconstruct (&mctx.input, match_first, eflags); if (BE (err != REG_NOERROR, 0)) goto free_return; #ifdef RE_ENABLE_I18N /* Eliminate it when it is a component of a multibyte character and isn't the head of a multibyte character. */ - if (sb || re_string_first_byte (&input, 0)) + if (sb || re_string_first_byte (&mctx.input, 0)) #endif { /* It seems to be appropriate one, then use the matcher. */ @@ -809,19 +808,19 @@ re_search_internal (preg, string, length if (pmatch[reg_idx].rm_so != -1) { #ifdef RE_ENABLE_I18N - if (BE (input.offsets_needed != 0, 0)) + if (BE (mctx.input.offsets_needed != 0, 0)) { - if (pmatch[reg_idx].rm_so == input.valid_len) - pmatch[reg_idx].rm_so += input.valid_raw_len - input.valid_len; + if (pmatch[reg_idx].rm_so == mctx.input.valid_len) + pmatch[reg_idx].rm_so += mctx.input.valid_raw_len - mctx.input.valid_len; else - pmatch[reg_idx].rm_so = input.offsets[pmatch[reg_idx].rm_so]; - if (pmatch[reg_idx].rm_eo == input.valid_len) - pmatch[reg_idx].rm_eo += input.valid_raw_len - input.valid_len; + pmatch[reg_idx].rm_so = mctx.input.offsets[pmatch[reg_idx].rm_so]; + if (pmatch[reg_idx].rm_eo == mctx.input.valid_len) + pmatch[reg_idx].rm_eo += mctx.input.valid_raw_len - mctx.input.valid_len; else - pmatch[reg_idx].rm_eo = input.offsets[pmatch[reg_idx].rm_eo]; + pmatch[reg_idx].rm_eo = mctx.input.offsets[pmatch[reg_idx].rm_eo]; } #else - assert (input.offsets_needed == 0); + assert (mctx.input.offsets_needed == 0); #endif pmatch[reg_idx].rm_so += match_first; pmatch[reg_idx].rm_eo += match_first; @@ -832,7 +831,7 @@ re_search_internal (preg, string, length re_free (mctx.state_log); if (dfa->nbackref) match_ctx_free (&mctx); - re_string_destruct (&input); + re_string_destruct (&mctx.input); return err; } @@ -938,7 +937,7 @@ acquire_init_state_context (err, preg, m if (dfa->init_state->has_constraint) { unsigned int context; - context = re_string_context_at (mctx->input, idx - 1, mctx->eflags); + context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags); if (IS_WORD_CONTEXT (context)) return dfa->init_state_word; else if (IS_ORDINARY_CONTEXT (context)) @@ -979,7 +978,7 @@ check_matching (preg, mctx, fl_longest_m reg_errcode_t err; int match = 0; int match_last = -1; - int cur_str_idx = re_string_cur_idx (mctx->input); + int cur_str_idx = re_string_cur_idx (&mctx->input); re_dfastate_t *cur_state; cur_state = acquire_init_state_context (&err, preg, mctx, cur_str_idx); @@ -1021,12 +1020,12 @@ check_matching (preg, mctx, fl_longest_m } } - while (!re_string_eoi (mctx->input)) + while (!re_string_eoi (&mctx->input)) { cur_state = transit_state (&err, preg, mctx, cur_state); if (cur_state == NULL) /* Reached at the invalid state or an error. */ { - cur_str_idx = re_string_cur_idx (mctx->input); + cur_str_idx = re_string_cur_idx (&mctx->input); if (BE (err != REG_NOERROR, 0)) return -2; if (!fl_longest_match && match) @@ -1053,10 +1052,10 @@ check_matching (preg, mctx, fl_longest_m Check the halt state can satisfy the current context. */ if (!cur_state->has_constraint || check_halt_state_context (preg, cur_state, mctx, - re_string_cur_idx (mctx->input))) + re_string_cur_idx (&mctx->input))) { /* We found an appropriate halt state. */ - match_last = re_string_cur_idx (mctx->input); + match_last = re_string_cur_idx (&mctx->input); match = 1; if (!fl_longest_match) break; @@ -1101,7 +1100,7 @@ check_halt_state_context (preg, state, m #ifdef DEBUG assert (state->halt); #endif - context = re_string_context_at (mctx->input, idx, mctx->eflags); + context = re_string_context_at (&mctx->input, idx, mctx->eflags); for (i = 0; i < state->nodes.nelem; ++i) if (check_halt_node_context (dfa, state->nodes.elems[i], context)) return state->nodes.elems[i]; @@ -1160,7 +1159,7 @@ proceed_next_node (preg, nregs, regs, mc #ifdef RE_ENABLE_I18N if (ACCEPT_MB_NODE (type)) - naccepted = check_node_accept_bytes (preg, node, mctx->input, *pidx); + naccepted = check_node_accept_bytes (preg, node, &mctx->input, *pidx); else #endif /* RE_ENABLE_I18N */ if (type == OP_BACK_REF) @@ -1173,7 +1172,7 @@ proceed_next_node (preg, nregs, regs, mc return -1; else if (naccepted) { - char *buf = (char *) re_string_get_buffer (mctx->input); + char *buf = (char *) re_string_get_buffer (&mctx->input); if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx, naccepted) != 0) return -1; @@ -1556,9 +1555,9 @@ clean_state_log_if_needed (mctx, next_st { int top = mctx->state_log_top; - if (next_state_log_idx >= mctx->input->bufs_len - || (next_state_log_idx >= mctx->input->valid_len - && mctx->input->valid_len < mctx->input->len)) + if (next_state_log_idx >= mctx->input.bufs_len + || (next_state_log_idx >= mctx->input.valid_len + && mctx->input.valid_len < mctx->input.len)) { reg_errcode_t err; err = extend_buffers (mctx); @@ -1977,7 +1976,7 @@ sift_states_bkref (preg, mctx, sctx, str for (node_idx = 0; node_idx < candidates->nelem; ++node_idx) { - int cur_bkref_idx = re_string_cur_idx (mctx->input); + int cur_bkref_idx = re_string_cur_idx (&mctx->input); re_token_type_t type; node = candidates->elems[node_idx]; type = dfa->nodes[node].type; @@ -2092,7 +2091,7 @@ sift_states_iter_mb (preg, mctx, sctx, n re_dfa_t *dfa = (re_dfa_t *) preg->buffer; int naccepted; /* Check the node can accept `multi byte'. */ - naccepted = check_node_accept_bytes (preg, node_idx, mctx->input, str_idx); + naccepted = check_node_accept_bytes (preg, node_idx, &mctx->input, str_idx); if (naccepted > 0 && str_idx + naccepted <= max_str_idx && !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], dfa->nexts[node_idx])) @@ -2126,9 +2125,9 @@ transit_state (err, preg, mctx, state) unsigned char ch; int cur_idx; - if (re_string_cur_idx (mctx->input) + 1 >= mctx->input->bufs_len - || (re_string_cur_idx (mctx->input) + 1 >= mctx->input->valid_len - && mctx->input->valid_len < mctx->input->len)) + if (re_string_cur_idx (&mctx->input) + 1 >= mctx->input.bufs_len + || (re_string_cur_idx (&mctx->input) + 1 >= mctx->input.valid_len + && mctx->input.valid_len < mctx->input.len)) { *err = extend_buffers (mctx); if (BE (*err != REG_NOERROR, 0)) @@ -2139,7 +2138,7 @@ transit_state (err, preg, mctx, state) if (state == NULL) { next_state = state; - re_string_skip_bytes (mctx->input, 1); + re_string_skip_bytes (&mctx->input, 1); } else { @@ -2157,7 +2156,7 @@ transit_state (err, preg, mctx, state) if (1) { /* Use transition table */ - ch = re_string_fetch_byte (mctx->input); + ch = re_string_fetch_byte (&mctx->input); trtable = state->trtable; if (trtable == NULL) { @@ -2172,8 +2171,8 @@ transit_state (err, preg, mctx, state) { unsigned int context; context - = re_string_context_at (mctx->input, - re_string_cur_idx (mctx->input) - 1, + = re_string_context_at (&mctx->input, + re_string_cur_idx (&mctx->input) - 1, mctx->eflags); if (IS_WORD_CONTEXT (context)) next_state = trtable[ch + SBC_MAX]; @@ -2194,7 +2193,7 @@ transit_state (err, preg, mctx, state) #endif } - cur_idx = re_string_cur_idx (mctx->input); + cur_idx = re_string_cur_idx (&mctx->input); /* Update the state_log if we need. */ if (mctx->state_log != NULL) { @@ -2231,8 +2230,8 @@ transit_state (err, preg, mctx, state) /* Note: We already add the nodes of the initial state, then we don't need to add them here. */ - context = re_string_context_at (mctx->input, - re_string_cur_idx (mctx->input) - 1, + context = re_string_context_at (&mctx->input, + re_string_cur_idx (&mctx->input) - 1, mctx->eflags); next_state = mctx->state_log[cur_idx] = re_acquire_state_context (err, dfa, &next_nodes, context); @@ -2317,7 +2316,7 @@ transit_state_sb (err, preg, state, mctx re_dfa_t *dfa = (re_dfa_t *) preg->buffer; re_node_set next_nodes; re_dfastate_t *next_state; - int node_cnt, cur_str_idx = re_string_cur_idx (mctx->input); + int node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input); unsigned int context; *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1); @@ -2337,13 +2336,13 @@ transit_state_sb (err, preg, state, mctx } } } - context = re_string_context_at (mctx->input, cur_str_idx, mctx->eflags); + context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags); next_state = re_acquire_state_context (err, dfa, &next_nodes, context); /* We don't need to check errors here, since the return value of this function is next_state and ERR is already set. */ re_node_set_free (&next_nodes); - re_string_skip_bytes (mctx->input, 1); + re_string_skip_bytes (&mctx->input, 1); return next_state; } #endif @@ -2369,8 +2368,8 @@ transit_state_mb (preg, pstate, mctx) if (dfa->nodes[cur_node_idx].constraint) { - context = re_string_context_at (mctx->input, - re_string_cur_idx (mctx->input), + context = re_string_context_at (&mctx->input, + re_string_cur_idx (&mctx->input), mctx->eflags); if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint, context)) @@ -2379,13 +2378,13 @@ transit_state_mb (preg, pstate, mctx) /* How many bytes the node can accept? */ if (ACCEPT_MB_NODE (dfa->nodes[cur_node_idx].type)) - naccepted = check_node_accept_bytes (preg, cur_node_idx, mctx->input, - re_string_cur_idx (mctx->input)); + naccepted = check_node_accept_bytes (preg, cur_node_idx, &mctx->input, + re_string_cur_idx (&mctx->input)); if (naccepted == 0) continue; /* The node can accepts `naccepted' bytes. */ - dest_idx = re_string_cur_idx (mctx->input) + naccepted; + dest_idx = re_string_cur_idx (&mctx->input) + naccepted; mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted : mctx->max_mb_elem_len); err = clean_state_log_if_needed (mctx, dest_idx); @@ -2408,7 +2407,7 @@ transit_state_mb (preg, pstate, mctx) if (BE (err != REG_NOERROR, 0)) return err; } - context = re_string_context_at (mctx->input, dest_idx - 1, mctx->eflags); + context = re_string_context_at (&mctx->input, dest_idx - 1, mctx->eflags); mctx->state_log[dest_idx] = re_acquire_state_context (&err, dfa, &dest_nodes, context); if (dest_state != NULL) @@ -2429,7 +2428,7 @@ transit_state_bkref (preg, nodes, mctx) reg_errcode_t err; re_dfa_t *dfa = (re_dfa_t *) preg->buffer; int i; - int cur_str_idx = re_string_cur_idx (mctx->input); + int cur_str_idx = re_string_cur_idx (&mctx->input); for (i = 0; i < nodes->nelem; ++i) { @@ -2445,7 +2444,7 @@ transit_state_bkref (preg, nodes, mctx) if (node->constraint) { - context = re_string_context_at (mctx->input, cur_str_idx, + context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags); if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) continue; @@ -2477,7 +2476,7 @@ transit_state_bkref (preg, nodes, mctx) : dfa->eclosures + dfa->nexts[node_idx]); dest_str_idx = (cur_str_idx + bkref_ent->subexp_to - bkref_ent->subexp_from); - context = re_string_context_at (mctx->input, dest_str_idx - 1, + context = re_string_context_at (&mctx->input, dest_str_idx - 1, mctx->eflags); dest_state = mctx->state_log[dest_str_idx]; prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0 @@ -2544,7 +2543,7 @@ get_subexp (preg, mctx, bkref_node, bkre { int subexp_num, sub_top_idx; re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - const char *buf = (const char *) re_string_get_buffer (mctx->input); + const char *buf = (const char *) re_string_get_buffer (&mctx->input); /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ int cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); for (; cache_idx < mctx->nbkref_ents; ++cache_idx) @@ -2591,7 +2590,7 @@ get_subexp (preg, mctx, bkref_node, bkre /* Reload buf, since the preceding call might have reallocated the buffer. */ - buf = (const char *) re_string_get_buffer (mctx->input); + buf = (const char *) re_string_get_buffer (&mctx->input); if (err == REG_NOMATCH) continue; @@ -2747,12 +2746,12 @@ check_arrival (preg, mctx, path, top_nod /* Temporary modify MCTX. */ backup_state_log = mctx->state_log; - backup_cur_idx = mctx->input->cur_idx; + backup_cur_idx = mctx->input.cur_idx; mctx->state_log = path->array; - mctx->input->cur_idx = str_idx; + mctx->input.cur_idx = str_idx; /* Setup initial node set. */ - context = re_string_context_at (mctx->input, str_idx - 1, mctx->eflags); + context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); if (str_idx == top_str) { err = re_node_set_init_1 (&next_nodes, top_node); @@ -2838,7 +2837,7 @@ check_arrival (preg, mctx, path, top_nod return err; } } - context = re_string_context_at (mctx->input, str_idx - 1, mctx->eflags); + context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); if (BE (cur_state == NULL && err != REG_NOERROR, 0)) { @@ -2855,7 +2854,7 @@ check_arrival (preg, mctx, path, top_nod /* Fix MCTX. */ mctx->state_log = backup_state_log; - mctx->input->cur_idx = backup_cur_idx; + mctx->input.cur_idx = backup_cur_idx; /* Then check the current node set has the node LAST_NODE. */ if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node)) @@ -2895,7 +2894,7 @@ check_arrival_add_next_nodes (preg, dfa, /* If the node may accept `multi byte'. */ if (ACCEPT_MB_NODE (type)) { - naccepted = check_node_accept_bytes (preg, cur_node, mctx->input, + naccepted = check_node_accept_bytes (preg, cur_node, &mctx->input, str_idx); if (naccepted > 1) { @@ -3872,12 +3871,12 @@ check_node_accept (preg, node, mctx, idx { /* The node has constraints. Check whether the current context satisfies the constraints. */ - unsigned int context = re_string_context_at (mctx->input, idx, + unsigned int context = re_string_context_at (&mctx->input, idx, mctx->eflags); if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) return 0; } - ch = re_string_byte_at (mctx->input, idx); + ch = re_string_byte_at (&mctx->input, idx); switch (node->type) { case CHARACTER: @@ -3905,7 +3904,7 @@ extend_buffers (mctx) re_match_context_t *mctx; { reg_errcode_t ret; - re_string_t *pstr = mctx->input; + re_string_t *pstr = &mctx->input; /* Double the lengthes of the buffers. */ ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); @@ -3960,13 +3959,11 @@ extend_buffers (mctx) /* Initialize MCTX. */ static reg_errcode_t -match_ctx_init (mctx, eflags, input, n) +match_ctx_init (mctx, eflags, n) re_match_context_t *mctx; int eflags, n; - re_string_t *input; { mctx->eflags = eflags; - mctx->input = input; mctx->match_last = -1; if (n > 0) { @@ -3975,12 +3972,13 @@ match_ctx_init (mctx, eflags, input, n) if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0)) return REG_ESPACE; } - else - mctx->bkref_ents = NULL; - mctx->nbkref_ents = 0; + /* Already zero-ed by the caller. + else + mctx->bkref_ents = NULL; + mctx->nbkref_ents = 0; + mctx->nsub_tops = 0; */ mctx->abkref_ents = n; mctx->max_mb_elem_len = 1; - mctx->nsub_tops = 0; mctx->asub_tops = n; return REG_NOERROR; } Jakub From jakub@redhat.com Fri Jan 2 17:21:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 02 Jan 2004 17:21:00 -0000 Subject: [PATCH] Don't pass preg around unnecessarily Message-ID: <20040102151428.GK2020@sunsite.ms.mff.cuni.cz> Hi! This patch on top of http://sources.redhat.com/ml/libc-hacker/2004-01/msg00000.html changes most of the const regex_t *preg passing around into passing re_dfa_t *dfa directly (with the exception of re_search_internal and its callers and set_regs). These functions were mainly interested just in preg->buffer (ie. dfa which is now passed around directly) and only rarely in preg->syntax (which makes sense to put into re_dfa_t). 2004-01-02 Jakub Jelinek * posix/regex_internal.h (re_dfa_t): Add syntax field. * posix/regcomp.c (parse): Initialize dfa->syntax. * posix/regexec.c (acquire_init_state_context, prune_impossible_nodes, check_matching, check_halt_state_context, proceed_next_node, sift_states_iter_mb, sift_states_backward, update_cur_sifted_state, sift_states_bkref, transit_state, transit_state_sb, transit_state_mb, transit_state_bkref, get_subexp, get_subexp_sub, check_arrival, expand_bkref_cache, build_trtable): Remove preg argument, add dfa argument instead and remove dfa = preg->buffer initialization in the body. Adjust all callers. (check_node_accept_bytes, group_nodes_into_DFAstates, check_node_accept): Likewise. Use dfa->syntax instead of preg->syntax. (check_arrival_add_next_nodes): Remove preg argument. --- libc/posix/regex_internal.h.jj 2004-01-02 16:17:11.000000000 +0100 +++ libc/posix/regex_internal.h 2004-01-02 17:20:23.000000000 +0100 @@ -636,6 +636,7 @@ struct re_dfa_t unsigned int word_ops_used : 1; int mb_cur_max; bitset word_char; + reg_syntax_t syntax; #ifdef DEBUG char* re_str; #endif --- libc/posix/regcomp.c.jj 2004-01-02 15:42:56.000000000 +0100 +++ libc/posix/regcomp.c 2004-01-02 17:23:18.000000000 +0100 @@ -1955,6 +1955,7 @@ parse (regexp, preg, syntax, err) re_dfa_t *dfa = (re_dfa_t *) preg->buffer; bin_tree_t *tree, *eor, *root; re_token_t current_token; + dfa->syntax = syntax; fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE); tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) --- libc/posix/regexec.c.jj 2004-01-02 16:17:11.000000000 +0100 +++ libc/posix/regexec.c 2004-01-02 17:29:41.000000000 +0100 @@ -51,21 +51,21 @@ static int re_search_stub (struct re_pat static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, int nregs, int regs_allocated) internal_function; static inline re_dfastate_t *acquire_init_state_context - (reg_errcode_t *err, const regex_t *preg, const re_match_context_t *mctx, + (reg_errcode_t *err, re_dfa_t *dfa, const re_match_context_t *mctx, int idx) __attribute ((always_inline)) internal_function; -static reg_errcode_t prune_impossible_nodes (const regex_t *preg, +static reg_errcode_t prune_impossible_nodes (re_dfa_t *dfa, re_match_context_t *mctx) internal_function; -static int check_matching (const regex_t *preg, re_match_context_t *mctx, +static int check_matching (re_dfa_t *dfa, re_match_context_t *mctx, int fl_longest_match) internal_function; static int check_halt_node_context (const re_dfa_t *dfa, int node, unsigned int context) internal_function; -static int check_halt_state_context (const regex_t *preg, +static int check_halt_state_context (re_dfa_t *dfa, const re_dfastate_t *state, const re_match_context_t *mctx, int idx) internal_function; static void update_regs (re_dfa_t *dfa, regmatch_t *pmatch, regmatch_t *prev_idx_match, int cur_node, int cur_idx, int nmatch) internal_function; -static int proceed_next_node (const regex_t *preg, int nregs, regmatch_t *regs, +static int proceed_next_node (re_dfa_t *dfa, int nregs, regmatch_t *regs, const re_match_context_t *mctx, int *pidx, int node, re_node_set *eps_via_nodes, struct re_fail_stack_t *fs) internal_function; @@ -82,15 +82,15 @@ static reg_errcode_t set_regs (const reg static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) internal_function; #ifdef RE_ENABLE_I18N -static int sift_states_iter_mb (const regex_t *preg, +static int sift_states_iter_mb (re_dfa_t *dfa, const re_match_context_t *mctx, re_sift_context_t *sctx, int node_idx, int str_idx, int max_str_idx) internal_function; #endif /* RE_ENABLE_I18N */ -static reg_errcode_t sift_states_backward (const regex_t *preg, +static reg_errcode_t sift_states_backward (re_dfa_t *dfa, re_match_context_t *mctx, re_sift_context_t *sctx) internal_function; -static reg_errcode_t update_cur_sifted_state (const regex_t *preg, +static reg_errcode_t update_cur_sifted_state (re_dfa_t *dfa, re_match_context_t *mctx, re_sift_context_t *sctx, int str_idx, @@ -113,7 +113,7 @@ static reg_errcode_t check_subexp_limits re_node_set *limits, struct re_backref_cache_entry *bkref_ents, int str_idx) internal_function; -static reg_errcode_t sift_states_bkref (const regex_t *preg, +static reg_errcode_t sift_states_bkref (re_dfa_t *dfa, re_match_context_t *mctx, re_sift_context_t *sctx, int str_idx, re_node_set *dest_nodes) internal_function; @@ -121,7 +121,7 @@ static reg_errcode_t clean_state_log_if_ int next_state_log_idx) internal_function; static reg_errcode_t merge_state_array (re_dfa_t *dfa, re_dfastate_t **dst, re_dfastate_t **src, int num) internal_function; -static re_dfastate_t *transit_state (reg_errcode_t *err, const regex_t *preg, +static re_dfastate_t *transit_state (reg_errcode_t *err, re_dfa_t *dfa, re_match_context_t *mctx, re_dfastate_t *state) internal_function; static reg_errcode_t check_subexp_matching_top (re_dfa_t *dfa, @@ -129,34 +129,33 @@ static reg_errcode_t check_subexp_matchi re_node_set *cur_nodes, int str_idx) internal_function; #if 0 -static re_dfastate_t *transit_state_sb (reg_errcode_t *err, const regex_t *preg, +static re_dfastate_t *transit_state_sb (reg_errcode_t *err, re_dfa_t *dfa, re_dfastate_t *pstate, re_match_context_t *mctx) internal_function; #endif #ifdef RE_ENABLE_I18N -static reg_errcode_t transit_state_mb (const regex_t *preg, +static reg_errcode_t transit_state_mb (re_dfa_t *dfa, re_dfastate_t *pstate, re_match_context_t *mctx) internal_function; #endif /* RE_ENABLE_I18N */ -static reg_errcode_t transit_state_bkref (const regex_t *preg, +static reg_errcode_t transit_state_bkref (re_dfa_t *dfa, const re_node_set *nodes, re_match_context_t *mctx) internal_function; -static reg_errcode_t get_subexp (const regex_t *preg, re_match_context_t *mctx, +static reg_errcode_t get_subexp (re_dfa_t *dfa, re_match_context_t *mctx, int bkref_node, int bkref_str_idx) internal_function; -static reg_errcode_t get_subexp_sub (const regex_t *preg, +static reg_errcode_t get_subexp_sub (re_dfa_t *dfa, re_match_context_t *mctx, const re_sub_match_top_t *sub_top, re_sub_match_last_t *sub_last, int bkref_node, int bkref_str) internal_function; static int find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, int subexp_idx, int type) internal_function; -static reg_errcode_t check_arrival (const regex_t *preg, +static reg_errcode_t check_arrival (re_dfa_t *dfa, re_match_context_t *mctx, state_array_t *path, int top_node, int top_str, int last_node, int last_str, int type) internal_function; -static reg_errcode_t check_arrival_add_next_nodes (const regex_t *preg, - re_dfa_t *dfa, +static reg_errcode_t check_arrival_add_next_nodes (re_dfa_t *dfa, re_match_context_t *mctx, int str_idx, re_node_set *cur_nodes, @@ -168,26 +167,26 @@ static reg_errcode_t check_arrival_expan re_node_set *dst_nodes, int target, int ex_subexp, int type) internal_function; -static reg_errcode_t expand_bkref_cache (const regex_t *preg, +static reg_errcode_t expand_bkref_cache (re_dfa_t *dfa, re_match_context_t *mctx, re_node_set *cur_nodes, int cur_str, int last_str, int subexp_num, int type) internal_function; -static re_dfastate_t **build_trtable (const regex_t *dfa, +static re_dfastate_t **build_trtable (re_dfa_t *dfa, re_dfastate_t *state) internal_function; #ifdef RE_ENABLE_I18N -static int check_node_accept_bytes (const regex_t *preg, int node_idx, +static int check_node_accept_bytes (re_dfa_t *dfa, int node_idx, const re_string_t *input, int idx) internal_function; # ifdef _LIBC static unsigned int find_collation_sequence_value (const unsigned char *mbs, size_t name_len) internal_function; # endif /* _LIBC */ #endif /* RE_ENABLE_I18N */ -static int group_nodes_into_DFAstates (const regex_t *dfa, +static int group_nodes_into_DFAstates (re_dfa_t *dfa, const re_dfastate_t *state, re_node_set *states_node, bitset *states_ch) internal_function; -static int check_node_accept (const regex_t *preg, const re_token_t *node, +static int check_node_accept (re_dfa_t *dfa, const re_token_t *node, const re_match_context_t *mctx, int idx) internal_function; static reg_errcode_t extend_buffers (re_match_context_t *mctx) internal_function; @@ -741,7 +740,7 @@ re_search_internal (preg, string, length /* It seems to be appropriate one, then use the matcher. */ /* We assume that the matching starts from 0. */ mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0; - match_last = check_matching (preg, &mctx, fl_longest_match); + match_last = check_matching (dfa, &mctx, fl_longest_match); if (match_last != -1) { if (BE (match_last == -2, 0)) @@ -755,13 +754,13 @@ re_search_internal (preg, string, length if ((!preg->no_sub && nmatch > 1) || dfa->nbackref) { re_dfastate_t *pstate = mctx.state_log[match_last]; - mctx.last_node = check_halt_state_context (preg, pstate, + mctx.last_node = check_halt_state_context (dfa, pstate, &mctx, match_last); } if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match) || dfa->nbackref) { - err = prune_impossible_nodes (preg, &mctx); + err = prune_impossible_nodes (dfa, &mctx); if (err == REG_NOERROR) break; if (BE (err != REG_NOMATCH, 0)) @@ -836,13 +835,12 @@ re_search_internal (preg, string, length } static reg_errcode_t -prune_impossible_nodes (preg, mctx) - const regex_t *preg; +prune_impossible_nodes (dfa, mctx) + re_dfa_t *dfa; re_match_context_t *mctx; { int halt_node, match_last; reg_errcode_t ret; - re_dfa_t *dfa = (re_dfa_t *)preg->buffer; re_dfastate_t **sifted_states; re_dfastate_t **lim_states = NULL; re_sift_context_t sctx; @@ -872,7 +870,7 @@ prune_impossible_nodes (preg, mctx) match_ctx_clear_flag (mctx); sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last, 0); - ret = sift_states_backward (preg, mctx, &sctx); + ret = sift_states_backward (dfa, mctx, &sctx); re_node_set_free (&sctx.limits); if (BE (ret != REG_NOERROR, 0)) goto free_return; @@ -888,7 +886,7 @@ prune_impossible_nodes (preg, mctx) } } while (mctx->state_log[match_last] == NULL || !mctx->state_log[match_last]->halt); - halt_node = check_halt_state_context (preg, + halt_node = check_halt_state_context (dfa, mctx->state_log[match_last], mctx, match_last); } @@ -903,7 +901,7 @@ prune_impossible_nodes (preg, mctx) { sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last, 0); - ret = sift_states_backward (preg, mctx, &sctx); + ret = sift_states_backward (dfa, mctx, &sctx); re_node_set_free (&sctx.limits); if (BE (ret != REG_NOERROR, 0)) goto free_return; @@ -925,14 +923,12 @@ prune_impossible_nodes (preg, mctx) since initial states may have constraints like "\<", "^", etc.. */ static inline re_dfastate_t * -acquire_init_state_context (err, preg, mctx, idx) +acquire_init_state_context (err, dfa, mctx, idx) reg_errcode_t *err; - const regex_t *preg; + re_dfa_t *dfa; const re_match_context_t *mctx; int idx; { - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - *err = REG_NOERROR; if (dfa->init_state->has_constraint) { @@ -969,19 +965,18 @@ acquire_init_state_context (err, preg, m index of the buffer. */ static int -check_matching (preg, mctx, fl_longest_match) - const regex_t *preg; +check_matching (dfa, mctx, fl_longest_match) + re_dfa_t *dfa; re_match_context_t *mctx; int fl_longest_match; { - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; reg_errcode_t err; int match = 0; int match_last = -1; int cur_str_idx = re_string_cur_idx (&mctx->input); re_dfastate_t *cur_state; - cur_state = acquire_init_state_context (&err, preg, mctx, cur_str_idx); + cur_state = acquire_init_state_context (&err, dfa, mctx, cur_str_idx); /* An initial state must not be NULL(invalid state). */ if (BE (cur_state == NULL, 0)) return -2; @@ -998,7 +993,7 @@ check_matching (preg, mctx, fl_longest_m if (cur_state->has_backref) { - err = transit_state_bkref (preg, &cur_state->nodes, mctx); + err = transit_state_bkref (dfa, &cur_state->nodes, mctx); if (BE (err != REG_NOERROR, 0)) return err; } @@ -1008,7 +1003,7 @@ check_matching (preg, mctx, fl_longest_m if (BE (cur_state->halt, 0)) { if (!cur_state->has_constraint - || check_halt_state_context (preg, cur_state, mctx, cur_str_idx)) + || check_halt_state_context (dfa, cur_state, mctx, cur_str_idx)) { if (!fl_longest_match) return cur_str_idx; @@ -1022,7 +1017,7 @@ check_matching (preg, mctx, fl_longest_m while (!re_string_eoi (&mctx->input)) { - cur_state = transit_state (&err, preg, mctx, cur_state); + cur_state = transit_state (&err, dfa, mctx, cur_state); if (cur_state == NULL) /* Reached at the invalid state or an error. */ { cur_str_idx = re_string_cur_idx (&mctx->input); @@ -1051,7 +1046,7 @@ check_matching (preg, mctx, fl_longest_m /* Reached at a halt state. Check the halt state can satisfy the current context. */ if (!cur_state->has_constraint - || check_halt_state_context (preg, cur_state, mctx, + || check_halt_state_context (dfa, cur_state, mctx, re_string_cur_idx (&mctx->input))) { /* We found an appropriate halt state. */ @@ -1088,13 +1083,12 @@ static int check_halt_node_context (dfa, match the context, return the node. */ static int -check_halt_state_context (preg, state, mctx, idx) - const regex_t *preg; +check_halt_state_context (dfa, state, mctx, idx) + re_dfa_t *dfa; const re_dfastate_t *state; const re_match_context_t *mctx; int idx; { - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; int i; unsigned int context; #ifdef DEBUG @@ -1113,15 +1107,14 @@ check_halt_state_context (preg, state, m of errors. */ static int -proceed_next_node (preg, nregs, regs, mctx, pidx, node, eps_via_nodes, fs) - const regex_t *preg; +proceed_next_node (dfa, nregs, regs, mctx, pidx, node, eps_via_nodes, fs) + re_dfa_t *dfa; regmatch_t *regs; const re_match_context_t *mctx; int nregs, *pidx, node; re_node_set *eps_via_nodes; struct re_fail_stack_t *fs; { - re_dfa_t *dfa = (re_dfa_t *)preg->buffer; int i, err, dest_node; dest_node = -1; if (IS_EPSILON_NODE (dfa->nodes[node].type)) @@ -1159,7 +1152,7 @@ proceed_next_node (preg, nregs, regs, mc #ifdef RE_ENABLE_I18N if (ACCEPT_MB_NODE (type)) - naccepted = check_node_accept_bytes (preg, node, &mctx->input, *pidx); + naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx); else #endif /* RE_ENABLE_I18N */ if (type == OP_BACK_REF) @@ -1192,7 +1185,7 @@ proceed_next_node (preg, nregs, regs, mc } if (naccepted != 0 - || check_node_accept (preg, dfa->nodes + node, mctx, *pidx)) + || check_node_accept (dfa, dfa->nodes + node, mctx, *pidx)) { dest_node = dfa->nexts[node]; *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted; @@ -1322,7 +1315,7 @@ set_regs (preg, mctx, nmatch, pmatch, fl } /* Proceed to next node. */ - cur_node = proceed_next_node (preg, nmatch, pmatch, mctx, &idx, cur_node, + cur_node = proceed_next_node (dfa, nmatch, pmatch, mctx, &idx, cur_node, &eps_via_nodes, fs); if (BE (cur_node < 0, 0)) @@ -1438,13 +1431,12 @@ update_regs (dfa, pmatch, prev_idx_match ((state) != NULL && re_node_set_contains (&(state)->nodes, node)) static reg_errcode_t -sift_states_backward (preg, mctx, sctx) - const regex_t *preg; +sift_states_backward (dfa, mctx, sctx) + re_dfa_t *dfa; re_match_context_t *mctx; re_sift_context_t *sctx; { reg_errcode_t err; - re_dfa_t *dfa = (re_dfa_t *)preg->buffer; int null_cnt = 0; int str_idx = sctx->last_str_idx; re_node_set cur_dest; @@ -1460,7 +1452,7 @@ sift_states_backward (preg, mctx, sctx) err = re_node_set_init_1 (&cur_dest, sctx->last_node); if (BE (err != REG_NOERROR, 0)) return err; - err = update_cur_sifted_state (preg, mctx, sctx, str_idx, &cur_dest); + err = update_cur_sifted_state (dfa, mctx, sctx, str_idx, &cur_dest); if (BE (err != REG_NOERROR, 0)) goto free_return; @@ -1499,7 +1491,7 @@ sift_states_backward (preg, mctx, sctx) #ifdef RE_ENABLE_I18N /* If the node may accept `multi byte'. */ if (ACCEPT_MB_NODE (type)) - naccepted = sift_states_iter_mb (preg, mctx, sctx, prev_node, + naccepted = sift_states_iter_mb (dfa, mctx, sctx, prev_node, str_idx, sctx->last_str_idx); #endif /* RE_ENABLE_I18N */ @@ -1507,7 +1499,7 @@ sift_states_backward (preg, mctx, sctx) See update_cur_sifted_state(). */ if (!naccepted - && check_node_accept (preg, dfa->nodes + prev_node, mctx, + && check_node_accept (dfa, dfa->nodes + prev_node, mctx, str_idx) && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1], dfa->nexts[prev_node])) @@ -1536,7 +1528,7 @@ sift_states_backward (preg, mctx, sctx) - It can epsilon transit to a node in CUR_DEST. - It is in CUR_SRC. And update state_log. */ - err = update_cur_sifted_state (preg, mctx, sctx, str_idx, &cur_dest); + err = update_cur_sifted_state (dfa, mctx, sctx, str_idx, &cur_dest); if (BE (err != REG_NOERROR, 0)) goto free_return; } @@ -1604,15 +1596,14 @@ merge_state_array (dfa, dst, src, num) } static reg_errcode_t -update_cur_sifted_state (preg, mctx, sctx, str_idx, dest_nodes) - const regex_t *preg; +update_cur_sifted_state (dfa, mctx, sctx, str_idx, dest_nodes) + re_dfa_t *dfa; re_match_context_t *mctx; re_sift_context_t *sctx; int str_idx; re_node_set *dest_nodes; { reg_errcode_t err; - re_dfa_t *dfa = (re_dfa_t *)preg->buffer; const re_node_set *candidates; candidates = ((mctx->state_log[str_idx] == NULL) ? &empty_set : &mctx->state_log[str_idx]->nodes); @@ -1643,7 +1634,7 @@ update_cur_sifted_state (preg, mctx, sct if ((mctx->state_log[str_idx] != NULL && mctx->state_log[str_idx]->has_backref)) { - err = sift_states_bkref (preg, mctx, sctx, str_idx, dest_nodes); + err = sift_states_bkref (dfa, mctx, sctx, str_idx, dest_nodes); if (BE (err != REG_NOERROR, 0)) return err; } @@ -1958,15 +1949,14 @@ check_subexp_limits (dfa, dest_nodes, ca } static reg_errcode_t -sift_states_bkref (preg, mctx, sctx, str_idx, dest_nodes) - const regex_t *preg; +sift_states_bkref (dfa, mctx, sctx, str_idx, dest_nodes) + re_dfa_t *dfa; re_match_context_t *mctx; re_sift_context_t *sctx; int str_idx; re_node_set *dest_nodes; { reg_errcode_t err; - re_dfa_t *dfa = (re_dfa_t *)preg->buffer; int node_idx, node; re_sift_context_t local_sctx; const re_node_set *candidates; @@ -2039,7 +2029,7 @@ sift_states_bkref (preg, mctx, sctx, str goto free_return; } cur_state = local_sctx.sifted_states[str_idx]; - err = sift_states_backward (preg, mctx, &local_sctx); + err = sift_states_backward (dfa, mctx, &local_sctx); if (BE (err != REG_NOERROR, 0)) goto free_return; if (sctx->limited_states != NULL) @@ -2082,16 +2072,15 @@ sift_states_bkref (preg, mctx, sctx, str #ifdef RE_ENABLE_I18N static int -sift_states_iter_mb (preg, mctx, sctx, node_idx, str_idx, max_str_idx) - const regex_t *preg; +sift_states_iter_mb (dfa, mctx, sctx, node_idx, str_idx, max_str_idx) + re_dfa_t *dfa; const re_match_context_t *mctx; re_sift_context_t *sctx; int node_idx, str_idx, max_str_idx; { - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; int naccepted; /* Check the node can accept `multi byte'. */ - naccepted = check_node_accept_bytes (preg, node_idx, &mctx->input, str_idx); + naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); if (naccepted > 0 && str_idx + naccepted <= max_str_idx && !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], dfa->nexts[node_idx])) @@ -2114,13 +2103,12 @@ sift_states_iter_mb (preg, mctx, sctx, n update the destination of STATE_LOG. */ static re_dfastate_t * -transit_state (err, preg, mctx, state) +transit_state (err, dfa, mctx, state) reg_errcode_t *err; - const regex_t *preg; + re_dfa_t *dfa; re_match_context_t *mctx; re_dfastate_t *state; { - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; re_dfastate_t **trtable, *next_state; unsigned char ch; int cur_idx; @@ -2146,7 +2134,7 @@ transit_state (err, preg, mctx, state) /* If the current state can accept multibyte. */ if (state->accept_mb) { - *err = transit_state_mb (preg, state, mctx); + *err = transit_state_mb (dfa, state, mctx); if (BE (*err != REG_NOERROR, 0)) return NULL; } @@ -2160,7 +2148,7 @@ transit_state (err, preg, mctx, state) trtable = state->trtable; if (trtable == NULL) { - trtable = build_trtable (preg, state); + trtable = build_trtable (dfa, state); if (trtable == NULL) { *err = REG_ESPACE; @@ -2186,7 +2174,7 @@ transit_state (err, preg, mctx, state) else { /* don't use transition table */ - next_state = transit_state_sb (err, preg, state, mctx); + next_state = transit_state_sb (err, dfa, state, mctx); if (BE (next_state == NULL && err != REG_NOERROR, 0)) return NULL; } @@ -2256,7 +2244,7 @@ transit_state (err, preg, mctx, state) /* If the next state has back references. */ if (next_state->has_backref) { - *err = transit_state_bkref (preg, &next_state->nodes, mctx); + *err = transit_state_bkref (dfa, &next_state->nodes, mctx); if (BE (*err != REG_NOERROR, 0)) return NULL; next_state = mctx->state_log[cur_idx]; @@ -2307,13 +2295,12 @@ check_subexp_matching_top (dfa, mctx, cu accepting the current input byte. */ static re_dfastate_t * -transit_state_sb (err, preg, state, mctx) +transit_state_sb (err, dfa, state, mctx) reg_errcode_t *err; - const regex_t *preg; + re_dfa_t *dfa; re_dfastate_t *state; re_match_context_t *mctx; { - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; re_node_set next_nodes; re_dfastate_t *next_state; int node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input); @@ -2325,7 +2312,7 @@ transit_state_sb (err, preg, state, mctx for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt) { int cur_node = state->nodes.elems[node_cnt]; - if (check_node_accept (preg, dfa->nodes + cur_node, mctx, cur_str_idx)) + if (check_node_accept (dfa, dfa->nodes + cur_node, mctx, cur_str_idx)) { *err = re_node_set_merge (&next_nodes, dfa->eclosures + dfa->nexts[cur_node]); @@ -2349,13 +2336,12 @@ transit_state_sb (err, preg, state, mctx #ifdef RE_ENABLE_I18N static reg_errcode_t -transit_state_mb (preg, pstate, mctx) - const regex_t *preg; +transit_state_mb (dfa, pstate, mctx) + re_dfa_t *dfa; re_dfastate_t *pstate; re_match_context_t *mctx; { reg_errcode_t err; - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; int i; for (i = 0; i < pstate->nodes.nelem; ++i) @@ -2378,7 +2364,7 @@ transit_state_mb (preg, pstate, mctx) /* How many bytes the node can accept? */ if (ACCEPT_MB_NODE (dfa->nodes[cur_node_idx].type)) - naccepted = check_node_accept_bytes (preg, cur_node_idx, &mctx->input, + naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input, re_string_cur_idx (&mctx->input)); if (naccepted == 0) continue; @@ -2420,13 +2406,12 @@ transit_state_mb (preg, pstate, mctx) #endif /* RE_ENABLE_I18N */ static reg_errcode_t -transit_state_bkref (preg, nodes, mctx) - const regex_t *preg; +transit_state_bkref (dfa, nodes, mctx) + re_dfa_t *dfa; const re_node_set *nodes; re_match_context_t *mctx; { reg_errcode_t err; - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; int i; int cur_str_idx = re_string_cur_idx (&mctx->input); @@ -2453,7 +2438,7 @@ transit_state_bkref (preg, nodes, mctx) /* `node' is a backreference. Check the substring which the substring matched. */ bkc_idx = mctx->nbkref_ents; - err = get_subexp (preg, mctx, node_idx, cur_str_idx); + err = get_subexp (dfa, mctx, node_idx, cur_str_idx); if (BE (err != REG_NOERROR, 0)) goto free_return; @@ -2518,7 +2503,7 @@ transit_state_bkref (preg, nodes, mctx) cur_str_idx); if (BE (err != REG_NOERROR, 0)) goto free_return; - err = transit_state_bkref (preg, new_dest_nodes, mctx); + err = transit_state_bkref (dfa, new_dest_nodes, mctx); if (BE (err != REG_NOERROR, 0)) goto free_return; } @@ -2536,13 +2521,12 @@ transit_state_bkref (preg, nodes, mctx) delay these checking for prune_impossible_nodes(). */ static reg_errcode_t -get_subexp (preg, mctx, bkref_node, bkref_str_idx) - const regex_t *preg; +get_subexp (dfa, mctx, bkref_node, bkref_str_idx) + re_dfa_t *dfa; re_match_context_t *mctx; int bkref_node, bkref_str_idx; { int subexp_num, sub_top_idx; - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; const char *buf = (const char *) re_string_get_buffer (&mctx->input); /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ int cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); @@ -2585,7 +2569,7 @@ get_subexp (preg, mctx, bkref_node, bkre break; /* We don't need to search this sub expression any more. */ bkref_str_off += sl_str_diff; sl_str += sl_str_diff; - err = get_subexp_sub (preg, mctx, sub_top, sub_last, bkref_node, + err = get_subexp_sub (dfa, mctx, sub_top, sub_last, bkref_node, bkref_str_idx); /* Reload buf, since the preceding call might have reallocated @@ -2629,7 +2613,7 @@ get_subexp (preg, mctx, bkref_node, bkre } /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node in the current context? */ - err = check_arrival (preg, mctx, sub_top->path, sub_top->node, + err = check_arrival (dfa, mctx, sub_top->path, sub_top->node, sub_top->str_idx, cls_node, sl_str, OP_CLOSE_SUBEXP); if (err == REG_NOMATCH) continue; @@ -2638,7 +2622,7 @@ get_subexp (preg, mctx, bkref_node, bkre sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str); if (BE (sub_last == NULL, 0)) return REG_ESPACE; - err = get_subexp_sub (preg, mctx, sub_top, sub_last, bkref_node, + err = get_subexp_sub (dfa, mctx, sub_top, sub_last, bkref_node, bkref_str_idx); if (err == REG_NOMATCH) continue; @@ -2654,8 +2638,8 @@ get_subexp (preg, mctx, bkref_node, bkre and SUB_LAST. */ static reg_errcode_t -get_subexp_sub (preg, mctx, sub_top, sub_last, bkref_node, bkref_str) - const regex_t *preg; +get_subexp_sub (dfa, mctx, sub_top, sub_last, bkref_node, bkref_str) + re_dfa_t *dfa; re_match_context_t *mctx; const re_sub_match_top_t *sub_top; re_sub_match_last_t *sub_last; @@ -2664,7 +2648,7 @@ get_subexp_sub (preg, mctx, sub_top, sub reg_errcode_t err; int to_idx; /* Can the subexpression arrive the back reference? */ - err = check_arrival (preg, mctx, &sub_last->path, sub_last->node, + err = check_arrival (dfa, mctx, &sub_last->path, sub_last->node, sub_last->str_idx, bkref_node, bkref_str, OP_OPEN_SUBEXP); if (err != REG_NOERROR) return err; @@ -2709,14 +2693,13 @@ find_subexp_node (dfa, nodes, subexp_idx Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */ static reg_errcode_t -check_arrival (preg, mctx, path, top_node, top_str, last_node, last_str, +check_arrival (dfa, mctx, path, top_node, top_str, last_node, last_str, type) - const regex_t *preg; + re_dfa_t *dfa; re_match_context_t *mctx; state_array_t *path; int top_node, top_str, last_node, last_str, type; { - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; reg_errcode_t err; int subexp_num, backup_cur_idx, str_idx, null_cnt; re_dfastate_t *cur_state = NULL; @@ -2780,7 +2763,7 @@ check_arrival (preg, mctx, path, top_nod { if (next_nodes.nelem) { - err = expand_bkref_cache (preg, mctx, &next_nodes, str_idx, last_str, + err = expand_bkref_cache (dfa, mctx, &next_nodes, str_idx, last_str, subexp_num, type); if (BE ( err != REG_NOERROR, 0)) { @@ -2812,7 +2795,7 @@ check_arrival (preg, mctx, path, top_nod } if (cur_state) { - err = check_arrival_add_next_nodes (preg, dfa, mctx, str_idx, + err = check_arrival_add_next_nodes (dfa, mctx, str_idx, &cur_state->nodes, &next_nodes); if (BE (err != REG_NOERROR, 0)) { @@ -2829,7 +2812,7 @@ check_arrival (preg, mctx, path, top_nod re_node_set_free (&next_nodes); return err; } - err = expand_bkref_cache (preg, mctx, &next_nodes, str_idx, last_str, + err = expand_bkref_cache (dfa, mctx, &next_nodes, str_idx, last_str, subexp_num, type); if (BE ( err != REG_NOERROR, 0)) { @@ -2872,8 +2855,7 @@ check_arrival (preg, mctx, path, top_nod Can't we unify them? */ static reg_errcode_t -check_arrival_add_next_nodes (preg, dfa, mctx, str_idx, cur_nodes, next_nodes) - const regex_t *preg; +check_arrival_add_next_nodes (dfa, mctx, str_idx, cur_nodes, next_nodes) re_dfa_t *dfa; re_match_context_t *mctx; int str_idx; @@ -2894,7 +2876,7 @@ check_arrival_add_next_nodes (preg, dfa, /* If the node may accept `multi byte'. */ if (ACCEPT_MB_NODE (type)) { - naccepted = check_node_accept_bytes (preg, cur_node, &mctx->input, + naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input, str_idx); if (naccepted > 1) { @@ -2930,7 +2912,7 @@ check_arrival_add_next_nodes (preg, dfa, } #endif /* RE_ENABLE_I18N */ if (naccepted - || check_node_accept (preg, dfa->nodes + cur_node, mctx, + || check_node_accept (dfa, dfa->nodes + cur_node, mctx, str_idx)) { err = re_node_set_insert (next_nodes, dfa->nexts[cur_node]); @@ -3051,15 +3033,14 @@ check_arrival_expand_ecl_sub (dfa, dst_n in MCTX->BKREF_ENTS. */ static reg_errcode_t -expand_bkref_cache (preg, mctx, cur_nodes, cur_str, last_str, subexp_num, +expand_bkref_cache (dfa, mctx, cur_nodes, cur_str, last_str, subexp_num, type) - const regex_t *preg; + re_dfa_t *dfa; re_match_context_t *mctx; int cur_str, last_str, subexp_num, type; re_node_set *cur_nodes; { reg_errcode_t err; - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; int cache_idx, cache_idx_start; /* The current state. */ @@ -3141,12 +3122,11 @@ expand_bkref_cache (preg, mctx, cur_node Return the new table if succeeded, otherwise return NULL. */ static re_dfastate_t ** -build_trtable (preg, state) - const regex_t *preg; +build_trtable (dfa, state) + re_dfa_t *dfa; re_dfastate_t *state; { reg_errcode_t err; - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; int i, j, ch; unsigned int elem, mask; int dests_node_malloced = 0, dest_states_malloced = 0; @@ -3181,7 +3161,7 @@ build_trtable (preg, state) /* At first, group all nodes belonging to `state' into several destinations. */ - ndests = group_nodes_into_DFAstates (preg, state, dests_node, dests_ch); + ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); if (BE (ndests <= 0, 0)) { if (dests_node_malloced) @@ -3369,14 +3349,13 @@ out_free: to DEST_CH[i]. This function return the number of destinations. */ static int -group_nodes_into_DFAstates (preg, state, dests_node, dests_ch) - const regex_t *preg; +group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch) + re_dfa_t *dfa; const re_dfastate_t *state; re_node_set *dests_node; bitset *dests_ch; { reg_errcode_t err; - const re_dfa_t *dfa = (re_dfa_t *) preg->buffer; int i, j, k; int ndests; /* Number of the destinations from `state'. */ bitset accepts; /* Characters a node can accept. */ @@ -3406,18 +3385,18 @@ group_nodes_into_DFAstates (preg, state, else #endif bitset_set_all (accepts); - if (!(preg->syntax & RE_DOT_NEWLINE)) + if (!(dfa->syntax & RE_DOT_NEWLINE)) bitset_clear (accepts, '\n'); - if (preg->syntax & RE_DOT_NOT_NULL) + if (dfa->syntax & RE_DOT_NOT_NULL) bitset_clear (accepts, '\0'); } #ifdef RE_ENABLE_I18N else if (type == OP_UTF8_PERIOD) { memset (accepts, 255, sizeof (unsigned int) * BITSET_UINTS / 2); - if (!(preg->syntax & RE_DOT_NEWLINE)) + if (!(dfa->syntax & RE_DOT_NEWLINE)) bitset_clear (accepts, '\n'); - if (preg->syntax & RE_DOT_NOT_NULL) + if (dfa->syntax & RE_DOT_NOT_NULL) bitset_clear (accepts, '\0'); } #endif @@ -3561,12 +3540,11 @@ group_nodes_into_DFAstates (preg, state, can only accept one byte. */ static int -check_node_accept_bytes (preg, node_idx, input, str_idx) - const regex_t *preg; +check_node_accept_bytes (dfa, node_idx, input, str_idx) + re_dfa_t *dfa; int node_idx, str_idx; const re_string_t *input; { - const re_dfa_t *dfa = (re_dfa_t *) preg->buffer; const re_token_t *node = dfa->nodes + node_idx; int char_len, elem_len; int i; @@ -3630,9 +3608,9 @@ check_node_accept_bytes (preg, node_idx, /* FIXME: I don't think this if is needed, as both '\n' and '\0' are char_len == 1. */ /* '.' accepts any one character except the following two cases. */ - if ((!(preg->syntax & RE_DOT_NEWLINE) && + if ((!(dfa->syntax & RE_DOT_NEWLINE) && re_string_byte_at (input, str_idx) == '\n') || - ((preg->syntax & RE_DOT_NOT_NULL) && + ((dfa->syntax & RE_DOT_NOT_NULL) && re_string_byte_at (input, str_idx) == '\0')) return 0; return char_len; @@ -3860,8 +3838,8 @@ find_collation_sequence_value (mbs, mbs_ byte of the INPUT. */ static int -check_node_accept (preg, node, mctx, idx) - const regex_t *preg; +check_node_accept (dfa, node, mctx, idx) + re_dfa_t *dfa; const re_token_t *node; const re_match_context_t *mctx; int idx; @@ -3890,8 +3868,8 @@ check_node_accept (preg, node, mctx, idx /* FALLTHROUGH */ #endif case OP_PERIOD: - return !((ch == '\n' && !(preg->syntax & RE_DOT_NEWLINE)) - || (ch == '\0' && (preg->syntax & RE_DOT_NOT_NULL))); + return !((ch == '\n' && !(dfa->syntax & RE_DOT_NEWLINE)) + || (ch == '\0' && (dfa->syntax & RE_DOT_NOT_NULL))); default: return 0; } Jakub From jakub@redhat.com Fri Jan 2 20:50:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 02 Jan 2004 20:50:00 -0000 Subject: [PATCH] Fix warnings on regex_internal.c Message-ID: <20040102184356.GL2020@sunsite.ms.mff.cuni.cz> Hi! regex-rewrite-node-set-insert.patch introduced 2 new warnings, cured by following patch: 2004-01-02 Jakub Jelinek * posix/regex_internal.c (re_node_set_insert): Remove unused variables. --- libc/posix/regex_internal.c.jj 2004-01-02 16:17:11.000000000 +0100 +++ libc/posix/regex_internal.c 2004-01-02 21:47:39.000000000 +0100 @@ -1162,7 +1162,7 @@ re_node_set_insert (set, elem) re_node_set *set; int elem; { - int idx, right, mid; + int idx; /* In case the set is empty. */ if (set->alloc == 0) { Jakub From aj@suse.de Sat Jan 3 09:39:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sat, 03 Jan 2004 09:39:00 -0000 Subject: regexec.c does not build Message-ID: Uli, did you forget to commit a patch? In file included from regex.c:54: regexec.c: In function `re_search_internal': regexec.c:572: error: unknown field `dfa' specified in initializer regexec.c:572: warning: missing braces around initializer regexec.c:572: warning: (near initialization for `mctx.input') regexec.c:572: warning: initialization from incompatible pointer type regexec.c: In function `prune_impossible_nodes': regexec.c:846: error: structure has no member named `dfa' regexec.c: In function `acquire_init_state_context': regexec.c:936: error: structure has no member named `dfa' regexec.c: In function `check_matching': regexec.c:977: error: structure has no member named `dfa' regexec.c: In function `check_halt_state_context': regexec.c:1103: error: structure has no member named `dfa' regexec.c: In function `proceed_next_node': regexec.c:1121: error: structure has no member named `dfa' regexec.c: In function `sift_states_backward': regexec.c:1442: error: structure has no member named `dfa' regexec.c: In function `update_cur_sifted_state': regexec.c:1608: error: structure has no member named `dfa' regexec.c: In function `check_dst_limits': This is current CVS, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Sat Jan 3 12:49:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 03 Jan 2004 12:49:00 -0000 Subject: regexec.c does not build In-Reply-To: References: Message-ID: <20040103104257.GN2020@sunsite.ms.mff.cuni.cz> On Sat, Jan 03, 2004 at 10:37:08AM +0100, Andreas Jaeger wrote: > > Uli, did you forget to commit a patch? > > In file included from regex.c:54: > regexec.c: In function `re_search_internal': > regexec.c:572: error: unknown field `dfa' specified in initializer > regexec.c:572: warning: missing braces around initializer > regexec.c:572: warning: (near initialization for `mctx.input') > regexec.c:572: warning: initialization from incompatible pointer type > regexec.c: In function `prune_impossible_nodes': > regexec.c:846: error: structure has no member named `dfa' > regexec.c: In function `acquire_init_state_context': > regexec.c:936: error: structure has no member named `dfa' > regexec.c: In function `check_matching': > regexec.c:977: error: structure has no member named `dfa' > regexec.c: In function `check_halt_state_context': > regexec.c:1103: error: structure has no member named `dfa' > regexec.c: In function `proceed_next_node': > regexec.c:1121: error: structure has no member named `dfa' > regexec.c: In function `sift_states_backward': > regexec.c:1442: error: structure has no member named `dfa' > regexec.c: In function `update_cur_sifted_state': > regexec.c:1608: error: structure has no member named `dfa' > regexec.c: In function `check_dst_limits': Seems the regex_internal.h part of the patch has not been commited. Also, perl -pi -e 's/mctxt/mctx/' ChangeLog (sorry for not providing ChangeLog entry yesterday). --- libc/posix/regex_internal.h.jj 2004-01-03 13:44:41.000000000 +0100 +++ libc/posix/regex_internal.h 2004-01-03 13:45:04.000000000 +0100 @@ -556,6 +556,11 @@ typedef struct { /* The string object corresponding to the input string. */ re_string_t input; +#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) + re_dfa_t *const dfa; +#else + re_dfa_t *dfa; +#endif /* EFLAGS of the argument of regexec. */ int eflags; /* Where the matching ends. */ Jakub From aj@suse.de Sat Jan 3 13:08:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sat, 03 Jan 2004 13:08:00 -0000 Subject: regexec.c does not build In-Reply-To: <20040103104257.GN2020@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Sat, 3 Jan 2004 11:42:57 +0100") References: <20040103104257.GN2020@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: >[...] > Seems the regex_internal.h part of the patch has not been commited. Thanks for providing that - I've committed it now. > Also, perl -pi -e 's/mctxt/mctx/' ChangeLog Ok, also done and committed, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Mon Jan 5 14:31:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 05 Jan 2004 14:31:00 -0000 Subject: [PATCH] Fix regex ->translate handling Message-ID: <20040105122410.GR2020@sunsite.ms.mff.cuni.cz> Hi! RE_TRANSLATE_TYPE is cleverly char * (used to be in old regex too), while all uses of it need to be (unsigned char) preg->translate[ch]. Without this patch (which makes internal vars use unsigned char *) bug-regex22 segfaults. Also, it seems old regex differentiated between "\W" and "\w" patterns when re.translate['W'] is 'w', so this patch makes that work as well. Though old regex apparently didn't consider de_DE.ISO-8859-1 '\xc4' or '\xd6' (translated to '\xe4' or '\xf6') as word consituent characters, though that was clearly old regex bug ( /* Jim Meyering writes: "... Some ctype macros are valid only for character codes that isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when using /bin/cc or gcc but without giving an ansi option). So, all ctype uses should be through macros like ISPRINT... If STDC_HEADERS is defined, then autoconf has verified that the ctype macros don't need to be guarded with references to isascii. ... Defining isascii to 1 should let any compiler worth its salt eliminate the && through constant folding." Solaris defines some of these symbols so we must undefine them first. */ # undef ISASCII # if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII) # define ISASCII(c) 1 # else # define ISASCII(c) isascii(c) # endif ... # define ISALNUM(c) (ISASCII (c) && isalnum (c)) ). 2004-01-05 Jakub Jelinek * posix/regcomp.c (build_charclass, buld_charclass_op): Change first argument to unsigned RE_TRANSLATE_TYPE. * posix/regex_internal.h (re_string_t): Change trans type to unsigned RE_TRANSLATE_TYPE. * posix/regex_internal.c (re_string_construct_common): Cast trans to unsigned RE_TRANSLATE_TYPE. (re_string_peek_byte_case, re_string_fetch_byte_case): Avoid fast path if pstr->trans. Never translate the character through pstr->trans. * posix/Makefile (tests): Add bug-regex22. (bug-regex22-ENV): Set. * posix/bug-regex22.c: New test. --- libc/posix/regcomp.c.jj 2004-01-02 23:48:33.000000000 +0100 +++ libc/posix/regcomp.c 2004-01-05 12:53:47.000000000 +0100 @@ -109,7 +109,7 @@ static reg_errcode_t build_equiv_class ( re_charset_t *mbcset, int *equiv_class_alloc, const unsigned char *name); -static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, +static reg_errcode_t build_charclass (unsigned RE_TRANSLATE_TYPE trans, re_bitset_ptr_t sbcset, re_charset_t *mbcset, int *char_class_alloc, @@ -118,12 +118,13 @@ static reg_errcode_t build_charclass (RE #else /* not RE_ENABLE_I18N */ static reg_errcode_t build_equiv_class (re_bitset_ptr_t sbcset, const unsigned char *name); -static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, +static reg_errcode_t build_charclass (unsigned RE_TRANSLATE_TYPE trans, re_bitset_ptr_t sbcset, const unsigned char *class_name, reg_syntax_t syntax); #endif /* not RE_ENABLE_I18N */ -static bin_tree_t *build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, +static bin_tree_t *build_charclass_op (re_dfa_t *dfa, + unsigned RE_TRANSLATE_TYPE trans, const unsigned char *class_name, const unsigned char *extra, int not, reg_errcode_t *err); @@ -3401,7 +3402,7 @@ build_charclass (trans, sbcset, mbcset, #else /* not RE_ENABLE_I18N */ build_charclass (trans, sbcset, class_name, syntax) #endif /* not RE_ENABLE_I18N */ - RE_TRANSLATE_TYPE trans; + unsigned RE_TRANSLATE_TYPE trans; re_bitset_ptr_t sbcset; const unsigned char *class_name; reg_syntax_t syntax; @@ -3476,7 +3477,7 @@ build_charclass (trans, sbcset, class_na static bin_tree_t * build_charclass_op (dfa, trans, class_name, extra, not, err) re_dfa_t *dfa; - RE_TRANSLATE_TYPE trans; + unsigned RE_TRANSLATE_TYPE trans; const unsigned char *class_name; const unsigned char *extra; int not; --- libc/posix/regex_internal.h.jj 2004-01-03 14:13:05.000000000 +0100 +++ libc/posix/regex_internal.h 2004-01-05 12:54:14.000000000 +0100 @@ -337,7 +337,7 @@ struct re_string_t the beginning of the input string. */ unsigned int tip_context; /* The translation passed as a part of an argument of re_compile_pattern. */ - RE_TRANSLATE_TYPE trans; + unsigned RE_TRANSLATE_TYPE trans; /* Copy of re_dfa_t's word_char. */ re_const_bitset_ptr_t word_char; /* 1 if REG_ICASE. */ --- libc/posix/regex_internal.c.jj 2004-01-03 13:42:55.000000000 +0100 +++ libc/posix/regex_internal.c 2004-01-05 14:48:00.000000000 +0100 @@ -189,7 +189,7 @@ re_string_construct_common (str, len, ps pstr->raw_mbs = (const unsigned char *) str; pstr->len = len; pstr->raw_len = len; - pstr->trans = trans; + pstr->trans = (unsigned RE_TRANSLATE_TYPE) trans; pstr->icase = icase ? 1 : 0; pstr->mbs_allocated = (trans != NULL || icase); pstr->mb_cur_max = dfa->mb_cur_max; @@ -758,7 +758,7 @@ re_string_peek_byte_case (pstr, idx) int ch, off; /* Handle the common (easiest) cases first. */ - if (BE (!pstr->icase, 1)) + if (BE (!pstr->mbs_allocated, 1)) return re_string_peek_byte (pstr, idx); #ifdef RE_ENABLE_I18N @@ -774,8 +774,6 @@ re_string_peek_byte_case (pstr, idx) #endif ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; - if (pstr->trans) - ch = pstr->trans[ch]; #ifdef RE_ENABLE_I18N /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I @@ -793,15 +791,13 @@ static unsigned char re_string_fetch_byte_case (pstr) re_string_t *pstr; { - int ch; - - if (BE (!pstr->icase, 1)) + if (BE (!pstr->mbs_allocated, 1)) return re_string_fetch_byte (pstr); #ifdef RE_ENABLE_I18N if (pstr->offsets_needed) { - int off; + int off, ch; /* For tr_TR.UTF-8 [[:islower:]] there is [[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip @@ -815,8 +811,6 @@ re_string_fetch_byte_case (pstr) off = pstr->offsets[pstr->cur_idx]; ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; - if (pstr->trans) - ch = pstr->trans[ch]; if (! isascii (ch)) return re_string_fetch_byte (pstr); @@ -827,10 +821,7 @@ re_string_fetch_byte_case (pstr) } #endif - ch = pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; - if (pstr->trans) - ch = pstr->trans[ch]; - return ch; + return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; } static void --- libc/posix/Makefile.jj 2003-12-04 14:47:27.000000000 +0100 +++ libc/posix/Makefile 2004-01-05 13:21:25.000000000 +0100 @@ -1,4 +1,4 @@ -# Copyright (C) 1991-1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1991-1999, 2000-2003, 2004 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -79,8 +79,8 @@ tests := tstgetopt testfnm runtests run bug-regex8 bug-regex9 bug-regex10 bug-regex11 bug-regex12 \ bug-regex13 bug-regex14 bug-regex15 bug-regex16 \ bug-regex17 bug-regex18 bug-regex19 bug-regex20 \ - bug-regex21 tst-nice tst-nanosleep transbug tst-rxspencer \ - tst-pcre tst-boost + bug-regex21 bug-regex22 tst-nice tst-nanosleep \ + transbug tst-rxspencer tst-pcre tst-boost ifeq (yes,$(build-shared)) test-srcs := globtest tests += wordexp-test tst-exec tst-spawn @@ -162,6 +162,7 @@ bug-regex17-ENV = LOCPATH=$(common-objpf bug-regex18-ENV = LOCPATH=$(common-objpfx)localedata bug-regex19-ENV = LOCPATH=$(common-objpfx)localedata bug-regex20-ENV = LOCPATH=$(common-objpfx)localedata +bug-regex22-ENV = LOCPATH=$(common-objpfx)localedata tst-rxspencer-ARGS = --utf8 rxspencer/tests tst-rxspencer-ENV = LOCPATH=$(common-objpfx)localedata tst-pcre-ARGS = PCRE.tests --- libc/posix/bug-regex22.c.jj 2004-01-05 12:57:31.000000000 +0100 +++ libc/posix/bug-regex22.c 2004-01-05 14:47:48.000000000 +0100 @@ -0,0 +1,109 @@ +/* Test re.translate != NULL. + Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2004. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include + +int +main (void) +{ + struct re_pattern_buffer re; + char trans[256]; + int i, result = 0; + const char *s; + + setlocale (LC_ALL, "de_DE.ISO-8859-1"); + + for (i = 0; i < 256; ++i) + trans[i] = tolower (i); + + re_set_syntax (RE_SYNTAX_POSIX_EGREP); + + memset (&re, 0, sizeof (re)); + re.translate = trans; + s = re_compile_pattern ("\\W", 2, &re); + + if (s != NULL) + { + printf ("failed to compile pattern \"\\W\": %s\n", s); + result = 1; + } + else + { + int ret = re_search (&re, "abc.de", 6, 0, 6, NULL); + if (ret != 3) + { + printf ("1st re_search returned %d\n", ret); + result = 1; + } + + ret = re_search (&re, "\xc4\xd6\xae\xf7", 4, 0, 4, NULL); + if (ret != 2) + { + printf ("2nd re_search returned %d\n", ret); + result = 1; + } + re.translate = NULL; + regfree (&re); + } + + memset (&re, 0, sizeof (re)); + re.translate = trans; + s = re_compile_pattern ("\\w", 2, &re); + + if (s != NULL) + { + printf ("failed to compile pattern \"\\w\": %s\n", s); + result = 1; + } + else + { + int ret = re_search (&re, ".,!abc", 6, 0, 6, NULL); + if (ret != 3) + { + printf ("3rd re_search returned %d\n", ret); + result = 1; + } + + ret = re_search (&re, "\xae\xf7\xc4\xd6", 4, 0, 4, NULL); + if (ret != 2) + { + printf ("4th re_search returned %d\n", ret); + result = 1; + } + re.translate = NULL; + regfree (&re); + } + + memset (&re, 0, sizeof (re)); + re.translate = trans; + s = re_compile_pattern ("[[:DIGIT:]]", 2, &re); + if (s == NULL) + { + printf ("compilation of \"[[:DIGIT:]]\" pattern unexpectedly succeeded: %s\n", + s); + result = 1; + } + + return result; +} Jakub From jakub@redhat.com Mon Jan 5 21:49:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 05 Jan 2004 21:49:00 -0000 Subject: [PATCH] Sync regfree with old regex Message-ID: <20040105194221.GS2020@sunsite.ms.mff.cuni.cz> Hi! Old regex was freeing preg->translate in regfree as well as clearing the fields so that the re_pattern_buffer can be immediately reused by another re_compile_pattern. This patch should make zero difference for the POSIX interface (regcomp initializes all those 4 fields and never sets preg->translate) and should bring regfree behaviour after re_compile_pattern to how it used to work (given the lack of good enough specification for the re_* API I think the old regex should be the ultimate specification). 2004-01-05 Jakub Jelinek * posix/regcomp.c (regcomp): Fix comment typo. (regfree): Free preg->translate, clear buffer, allocated, fastmap and translate fields. --- libc/posix/regcomp.c.jj 2004-01-05 12:53:47.000000000 +0100 +++ libc/posix/regcomp.c 2004-01-05 21:37:17.000000000 +0100 @@ -503,7 +503,7 @@ regcomp (preg, pattern, cflags) /* We have already checked preg->fastmap != NULL. */ if (BE (ret == REG_NOERROR, 1)) /* Compute the fastmap now, since regexec cannot modify the pattern - buffer. This function nevers fails in this implementation. */ + buffer. This function never fails in this implementation. */ (void) re_compile_fastmap (preg); else { @@ -632,8 +632,14 @@ regfree (preg) re_dfa_t *dfa = (re_dfa_t *) preg->buffer; if (BE (dfa != NULL, 1)) free_dfa_content (dfa); + preg->buffer = NULL; + preg->allocated = 0; re_free (preg->fastmap); + preg->fastmap = NULL; + + re_free (preg->translate); + preg->translate = NULL; } #ifdef _LIBC weak_alias (__regfree, regfree) Jakub From roland@redhat.com Tue Jan 6 09:38:00 2004 From: roland@redhat.com (Roland McGrath) Date: Tue, 06 Jan 2004 09:38:00 -0000 Subject: using bugzilla for libc Message-ID: <200401060938.i069cteV014901@magilla.sf.frob.com> The bugzilla setup now in use on gcc.gnu.org is going to be available for tracking bugs in glibc as well (also binutils). Not quite all the pieces are in place yet for using bugzilla, but an important step now is to figure out how we're going to use it. (In case anyone didn't know, the gnu.org gnats setup has been utterly unusable for a long time, and now the host is completely dead; we've given up on it completely. It remains to be seen whether the old data from gnats reports can be salvaged, or even should be.) What you can do right now is go to http://sources.redhat.com/bugzilla/ make yourself an account, using whatever email address you want bugzilla to send you mail at. This is on the same machine as gcc.gnu.org/bugzilla, but is a distinct database with separate accounts, so if you already use GCC bugzilla, that's not directly relevant (except you already know how to use it). Note there is no SSL for this site; it is all insecure. So be sure not to use a password there that you use for anything else. There is a mailing list for people involved in shepherding the bugzilla setup (for GCC and the new one). You don't need to get on that mailing list unless you want to worry about administrivia and picayune technical issues with bugzilla itself. (I'm on it to represent glibc developers' use of bugzilla, and I'll let you know here if anything interesting comes up.) But if you want to get on it, mail . The utility of having a functioning bug tracking system for libc development will hinge on us establishing ways to use it efficiently and productively. GOTO Masanori has volunteered to do bug triage, and bugzilla being useful will depend greatly on these efforts. The first thing I would like to discuss about using bugzilla is a set of components. (There are several other important issues on my agenda to figure out, but I'm going to get the ball rolling just with this one and bring up the others after your initial feedback.) In bugzilla's parlance, glibc is our "product" and we get to pick a set of "components" into which it's divided up for purposes of grouping bug reports. The essential meaning of a component is that it has an owner, which is the person assigned to contemplate the bug report first. It's also a selector easy to use in queries when you are collecting lists of bugs. In the case of libc, you could call a zillion things "components" logically, or say it's all just libc. I think the useful kind of component to distinguish is along the lines of how things are maintained in practice. Here is an initial set of components off the cuff, with a tentative idea of who the "owner" might be. This is just an example of what we might use. I'm asking for ideas. regex jakub nis kukuk linuxthreads jakub nptl drepper manual roland? localedata pere libm libc rtld means gotom, but perhaps instead a pseudouser that is a mailing list of multiple volunteers. Any of the others might also instead be a mailing list: manual-triage, localedata-triage, etc. The idea is that e.g. locale-related reports would go initially to Petter (or his group of volunteers), who would verify the problem, work out a good concise test case and perhaps a fix, and post to libc-hacker for help (or just approval if they fixed it). Likewise, most bugs would go to Masanori (or his group of volunteers) who would then reclassify them to the appropriate component and (unless reclassified to a component with its own triage team, like localedata) verify them and post the concise reports to libc-hacker. If someone on the list starts looking into the bug, he should update bugzilla to show it assigned to him, then update it again when the fix has been committed. Comments? Thanks, Roland From jbailey@nisa.net Tue Jan 6 14:19:00 2004 From: jbailey@nisa.net (Jeff Bailey) Date: Tue, 06 Jan 2004 14:19:00 -0000 Subject: using bugzilla for libc In-Reply-To: <200401060938.i069cteV014901@magilla.sf.frob.com> References: <200401060938.i069cteV014901@magilla.sf.frob.com> Message-ID: <1073398778.1323.11.camel@outpost.dnsalias.org> Not exactly components, but two things that come to mind: Is it possible to have it also automatically cc: based on the host triple selected? It would be useful to have some of us involved with Hurd development able to see any bugs filed here automatically. I imagine other non-Linux targets would probably find this useful, too. Should we have a keyword or component for designating a function that's also in gnulib? For those who haven't seen it, gcc has a webpage[0] showing what they consider the various severities to mean. [0] http://gcc.gnu.org/bugs/management.html Tks, Jeff Bailey -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: From drepper@redhat.com Tue Jan 6 22:02:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 06 Jan 2004 22:02:00 -0000 Subject: [PATCH] Sync regfree with old regex In-Reply-To: <20040105194221.GS2020@sunsite.ms.mff.cuni.cz> References: <20040105194221.GS2020@sunsite.ms.mff.cuni.cz> Message-ID: <3FFB2FD6.2080505@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've applied the two regex patches. Thanks, - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/+y/a2ijCOnn/RHQRAuMQAJ9Z1af2JJkKcn7NcyeI4Bx1oNanjACeOiqv gSsaJ6pmRmICrg809l+UxsU= =mQoN -----END PGP SIGNATURE----- From roland@redhat.com Wed Jan 7 08:30:00 2004 From: roland@redhat.com (Roland McGrath) Date: Wed, 07 Jan 2004 08:30:00 -0000 Subject: using bugzilla for libc In-Reply-To: Jeff Bailey's message of Tuesday, 6 January 2004 09:19:38 -0500 <1073398778.1323.11.camel@outpost.dnsalias.org> Message-ID: <200401070830.i078ULdE004445@magilla.sf.frob.com> > Is it possible to have it also automatically cc: based on > the host triple selected? Not so far as I know. You can always do regular queries for newly-appeared/changed bugs matching some fields you are interested in. > It would be useful to have some of us involved with Hurd development able > to see any bugs filed here automatically. I imagine other non-Linux > targets would probably find this useful, too. I think hurd should be a component, referring to the hurd-specific code. I forgot to put that on my initial list. > Should we have a keyword or component for designating a function > that's also in gnulib? I don't really know what keywords mean. The functions copied by gnulib are a random smattering of unrelated things as far as libc or a user is concerned. I don't think this kind of thing is the most useful way to make sure changes affecting gnulib get tracked. gnulib maintainers can file bugs in libc bugzilla for changes they need in the libc files they copy, if that is useful for their tracking. For gnulib maintainers to keep abreast of changes in those files, they should simply be watching ChangeLog or the cvs commit mail for the files of interest (you could set up something automatic to do this pretty easily). > For those who haven't seen it, gcc has a webpage[0] showing > what they consider the various severities to mean. > > [0] http://gcc.gnu.org/bugs/management.html Everything on that page is reasonably sensible for glibc as well. A little of what it says compiler-specific, but it's obvious how to map it. Thanks, Roland From jakub@redhat.com Wed Jan 7 17:13:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 07 Jan 2004 17:13:00 -0000 Subject: Malloc not trimming sbrk space once it fills up Message-ID: <20040107150553.GA6413@sunsite.ms.mff.cuni.cz> Hi! The attached testcase shows that once morecore fails for the first time and malloc needs to fall back into mmap arena, no more sbrk trimming happens even if all chunks in mmap areas are freed. Jakub -------------- next part -------------- /* Copyright (C) 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2004. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include #include #include #include #include ptrdiff_t sum; __malloc_ptr_t counting_morecore (ptrdiff_t size) { sum += size; return __default_morecore (size); } int main (void) { size_t pagesize = sysconf (_SC_PAGESIZE); char *p = sbrk (0); p += (128 * pagesize) & ~(pagesize - 1); if (mmap (p, pagesize, PROT_NONE, MAP_PRIVATE|MAP_ANON, -1, 0) != p) { puts ("Couldn't test"); return 0; } if (mallopt (M_TRIM_THRESHOLD, 32 * pagesize) == 0) { puts ("Couldn't test"); return 0; } __morecore = counting_morecore; char *array[512]; int i; for (i = 0; i < 512; ++i) array[i] = malloc (pagesize / 4); ptrdiff_t midsum = sum; for (i = 511; i >= 0; --i) free (array[i]); __morecore = __default_morecore; if (midsum == sum && midsum > 32 * pagesize) { printf ("free did not trim sbrk area at all: midsum %td sum %td\n", midsum, sum); return 1; } return 0; } From wmglo@dent.med.uni-muenchen.de Wed Jan 7 18:29:00 2004 From: wmglo@dent.med.uni-muenchen.de (wmglo@dent.med.uni-muenchen.de) Date: Wed, 07 Jan 2004 18:29:00 -0000 Subject: Malloc not trimming sbrk space once it fills up In-Reply-To: <20040107150553.GA6413@sunsite.ms.mff.cuni.cz> (message from Jakub Jelinek on Wed, 7 Jan 2004 16:05:53 +0100) References: <20040107150553.GA6413@sunsite.ms.mff.cuni.cz> Message-ID: <20040107182858.9269.qmail@md.dent.med.uni-muenchen.de> Hi, > The attached testcase shows that once morecore fails for the first time > and malloc needs to fall back into mmap arena, no more sbrk trimming > happens even if all chunks in mmap areas are freed. Thanks for the testcase, but this is to be expected. Do you think this course of events is common enough to warrant a change? I'll take a look whether it can be changed easily. Regards, Wolfram. From jakub@redhat.com Thu Jan 8 10:48:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 08 Jan 2004 10:48:00 -0000 Subject: Malloc not trimming sbrk space once it fills up In-Reply-To: <20040107182858.9269.qmail@md.dent.med.uni-muenchen.de> References: <20040107150553.GA6413@sunsite.ms.mff.cuni.cz> <20040107182858.9269.qmail@md.dent.med.uni-muenchen.de> Message-ID: <20040108084024.GB6413@sunsite.ms.mff.cuni.cz> On Wed, Jan 07, 2004 at 06:28:58PM -0000, wmglo@dent.med.uni-muenchen.de wrote: > Hi, > > > The attached testcase shows that once morecore fails for the first time > > and malloc needs to fall back into mmap arena, no more sbrk trimming > > happens even if all chunks in mmap areas are freed. > > Thanks for the testcase, but this is to be expected. > > Do you think this course of events is common enough to warrant a > change? We've got a bug report about it, so probably some people ran into it. I can imagine some programs which normally don't use too much memory but at peak times need a few gigs. It is less urgent with the kernel changes in RHEL3/Fedora Core 1 where mmap allocates from top to bottom, so most of the memory is usable as brk area unless mmap is used with non-NULL first argument. > I'll take a look whether it can be changed easily. Thanks. Jakub From jakub@redhat.com Thu Jan 8 15:49:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 08 Jan 2004 15:49:00 -0000 Subject: [PATCH] Fix AMD64 backtrace Message-ID: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> Hi! The cfi_startproc hidden in x86_64's ENTRY and cfi_endproc in END macros causes several routines to have incorrect unwind info. I went through them and the problems are in at least: libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S libc/sysdeps/unix/sysv/linux/x86_64/__start_context.S libc/sysdeps/unix/sysv/linux/x86_64/clone.S libc/sysdeps/unix/sysv/linux/x86_64/getcontext.S libc/sysdeps/unix/sysv/linux/x86_64/setcontext.S libc/sysdeps/unix/sysv/linux/x86_64/swapcontext.S libc/sysdeps/unix/sysv/linux/x86_64/sysdep.S libc/sysdeps/unix/sysv/linux/x86_64/vfork.S libc/sysdeps/unix/x86_64/sysdep.S libc/sysdeps/x86_64/__longjmp.S libc/sysdeps/x86_64/strcspn.S libc/sysdeps/x86_64/strspn.S (that's all .S x86_64 files which use ENTRY/END, don't use any cfi_* directives, and don't maintain constant %rsp over its lifetime or clobber call saved registers). The testcase below segfaults on AMD64, because thread_start part of __clone has incorrect unwind info. I don't think there is any frame info termination on AMD64 (e.g. when context->ra is 0 libgcc segfaults), so I'd say it is better to avoid the unwind info in that case altogether, which will cause e.g. backtrace to stop. I've terminated the FDE already before syscall, because then the unwind info would need to differentiate between %rax == 0 (terminate unwind info chain; how?) and %rax != 0 (the current DW_CFA_nop should be sufficient). For the remaining of the above failes, either they should start using ENTRY_NOCFI/END_NOCFI, or, IMHO better given that GCC defaults to -fasynchronous-unwind-tables on AMD64, cfi_* directives should be added. 2004-01-08 Jakub Jelinek * sysdeps/unix/sysv/linux/x86_64/clone.S (__clone): Add cfi_endproc right before syscall and cfi_startproc before PSEUDO_END. Clear %rbp in thread_start. nptl/ * Makefile (tests): Add tst-backtrace1. * tst-backtrace1.c: New test. --- libc/sysdeps/unix/sysv/linux/x86_64/clone.S.jj 2003-03-04 20:45:35.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/x86_64/clone.S 2004-01-08 16:20:37.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -72,6 +72,10 @@ ENTRY (BP_SYM (__clone)) movq %r9, %r8 movq 8(%rsp), %r10 movq $SYS_ify(clone),%rax + + /* End FDE now, because in the child the unwind info will be + wrong. */ + cfi_endproc; syscall testq %rax,%rax @@ -82,6 +86,10 @@ L(pseudo_end): ret thread_start: + /* Clear the frame pointer. The ABI suggests this be done, to mark + the outermost frame obviously. */ + xorq %rbp, %rbp + /* Set up arguments for the function call. */ popq %rax /* Function to call. */ popq %rdi /* Argument. */ @@ -90,6 +98,7 @@ thread_start: movq %rax, %rdi call HIDDEN_JUMPTARGET (_exit) + cfi_startproc; PSEUDO_END (BP_SYM (__clone)) weak_alias (BP_SYM (__clone), BP_SYM (clone)) --- libc/nptl/Makefile.jj 2003-12-29 15:01:27.000000000 +0100 +++ libc/nptl/Makefile 2004-01-08 16:25:24.000000000 +0100 @@ -1,4 +1,4 @@ -# Copyright (C) 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -235,6 +235,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 \ tst-clock1 tst-clock2 \ tst-context1 \ tst-sched1 \ + tst-backtrace1 \ tst-oddstacklimit # This sets the stack resource limit to 1023kb, which is not a multiple --- libc/nptl/tst-backtrace1.c.jj 2004-01-08 16:24:13.000000000 +0100 +++ libc/nptl/tst-backtrace1.c 2004-01-08 16:24:06.000000000 +0100 @@ -0,0 +1,86 @@ +/* Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2004. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#define BT_SIZE 64 +void *bt_array[BT_SIZE]; +int bt_cnt; + +int +do_bt (void) +{ + bt_cnt = backtrace (bt_array, BT_SIZE); + return 56; +} + +int +call_do_bt (void) +{ + return do_bt () + 1; +} + +void * +tf (void *arg) +{ + if (call_do_bt () != 57) + return (void *) 1L; + return NULL; +} + +int +do_test (void) +{ + pthread_t th; + if (pthread_create (&th, NULL, tf, NULL)) + { + puts ("create failed"); + return 1; + } + + void *res; + if (pthread_join (th, &res)) + { + puts ("join failed"); + return 1; + } + + if (res != NULL) + { + puts ("thread failed"); + return 1; + } + + char **text = backtrace_symbols (bt_array, bt_cnt); + if (text == NULL) + { + puts ("backtrace_symbols failed"); + return 1; + } + + for (int i = 0; i < bt_cnt; ++i) + puts (text[i]); + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" Jakub From drepper@redhat.com Thu Jan 8 18:24:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 08 Jan 2004 18:24:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> Message-ID: <3FFD9FD7.1070801@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jakub Jelinek wrote: > * sysdeps/unix/sysv/linux/x86_64/clone.S (__clone): Add cfi_endproc > right before syscall and cfi_startproc before PSEUDO_END. > Clear %rbp in thread_start. > nptl/ > * Makefile (tests): Add tst-backtrace1. > * tst-backtrace1.c: New test. I've applied the patch. Thanks, - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE//Z/X2ijCOnn/RHQRAgc9AKC2g9fd39r19XMsu1FkVSwiOCox0ACfTq9G oRQUNIEDwjIaqdg990OXN+A= =8mpq -----END PGP SIGNATURE----- From aj@suse.de Sat Jan 10 16:10:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sat, 10 Jan 2004 16:10:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Thu, 8 Jan 2004 14:42:16 +0100") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Hi! > > The cfi_startproc hidden in x86_64's ENTRY and cfi_endproc in END macros > causes several routines to have incorrect unwind info. > I went through them and the problems are in at least: > libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S Fixed. > libc/sysdeps/unix/sysv/linux/x86_64/__start_context.S Fixed. > libc/sysdeps/unix/sysv/linux/x86_64/clone.S Done by yourself. > libc/sysdeps/unix/sysv/linux/x86_64/getcontext.S I don't see a problem here directly. Am I missing something? > libc/sysdeps/unix/sysv/linux/x86_64/setcontext.S Adding right cfi directives here is not easy. What do you think of my patch? It's just the minimal solution or do we need to do more? Should we mark all call-clobbered registers with "cfi_undefined"? > libc/sysdeps/unix/sysv/linux/x86_64/swapcontext.S Let's get setcontext and getcontext fixed first... > libc/sysdeps/unix/sysv/linux/x86_64/sysdep.S Fixed (includes sysdeps/unix/x86_64/sysdep.S which is the problem). > libc/sysdeps/unix/sysv/linux/x86_64/vfork.S Fixed. > libc/sysdeps/unix/x86_64/sysdep.S Fixed. > libc/sysdeps/x86_64/__longjmp.S What's the best way to handle the destroying of the registers with CFI? Should we just mark the registers with "cfi_undefined"? > libc/sysdeps/x86_64/strcspn.S > libc/sysdeps/x86_64/strspn.S And those two are also fixed. I'm appending a patch. Can you give it a quick review, please? > (that's all .S x86_64 files which use ENTRY/END, don't use any cfi_* > directives, and don't maintain constant %rsp over its lifetime or > clobber call saved registers). > > The testcase below segfaults on AMD64, because thread_start part of __clone > has incorrect unwind info. > I don't think there is any frame info termination on AMD64 > (e.g. when context->ra is 0 libgcc segfaults), so I'd say it is better to > avoid the unwind info in that case altogether, which will cause e.g. > backtrace to stop. I've terminated the FDE already before syscall, > because then the unwind info would need to differentiate between > %rax == 0 (terminate unwind info chain; how?) and %rax != 0 (the current > DW_CFA_nop should be sufficient). > > For the remaining of the above failes, either they should start using > ENTRY_NOCFI/END_NOCFI, or, IMHO better given that GCC defaults to > -fasynchronous-unwind-tables on AMD64, cfi_* directives should be added. I agree. Thanks for reminding me about this and for your patch! Andreas 2004-01-10 Andreas Jaeger * sysdeps/unix/sysv/linux/x86_64/__start_context.S: Add cfi directives. * sysdeps/unix/x86_64/sysdep.S (__syscall_error): Likewise. * sysdeps/unix/sysv/linux/x86_64/vfork.S: Likewise. * sysdeps/x86_64/strcspn.S: Likewise. * sysdeps/x86_64/strspn.S: Likewise. For linuxthreads: * sysdeps/unix/sysv/linux/x86_64/vfork.S: Add cfi directives. ============================================================ Index: sysdeps/unix/sysv/linux/x86_64/__start_context.S --- sysdeps/unix/sysv/linux/x86_64/__start_context.S 27 Aug 2003 23:03:41 -0000 1.2 +++ sysdeps/unix/sysv/linux/x86_64/__start_context.S 10 Jan 2004 16:09:40 -0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 2002. @@ -33,6 +33,7 @@ ENTRY(__start_context) movq %rbx, %rsp popq %rdi /* This is the next context. */ + cfi_adjust_cfa_offset(-8) testq %rdi, %rdi je 2f /* If it is zero exit. */ ============================================================ Index: sysdeps/unix/sysv/linux/x86_64/vfork.S --- sysdeps/unix/sysv/linux/x86_64/vfork.S 31 Dec 2002 20:37:32 -0000 1.5 +++ sysdeps/unix/sysv/linux/x86_64/vfork.S 10 Jan 2004 16:09:41 -0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -30,6 +30,7 @@ ENTRY (__vfork) /* Pop the return PC value into RDI. We need a register that is preserved by the syscall and that we're allowed to destroy. */ popq %rdi + cfi_adjust_cfa_offset(-8) /* Stuff the syscall number in RAX and enter into the kernel. */ movl $SYS_ify (vfork), %eax @@ -37,6 +38,7 @@ ENTRY (__vfork) /* Push back the return PC. */ pushq %rdi + cfi_adjust_cfa_offset(8) cmpl $-4095, %eax jae SYSCALL_ERROR_LABEL /* Branch forward if it failed. */ ============================================================ Index: sysdeps/unix/x86_64/sysdep.S --- sysdeps/unix/x86_64/sysdep.S 11 Oct 2002 10:52:03 -0000 1.4 +++ sysdeps/unix/x86_64/sysdep.S 10 Jan 2004 16:09:41 -0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -57,10 +57,12 @@ notb: movl %eax, C_SYMBOL_NAME(errno) # else pushq %rax + cfi_adjust_cfa_offset(8) PUSH_ERRNO_LOCATION_RETURN call BP_SYM (__errno_location) POP_ERRNO_LOCATION_RETURN popq %rcx + cfi_adjust_cfa_offset(-8) movl %ecx, (%rax) # endif #else @@ -72,10 +74,12 @@ notb: movl %eax, (%rcx) # else pushq %rax + cfi_adjust_cfa_offset(8) PUSH_ERRNO_LOCATION_RETURN call C_SYMBOL_NAME (BP_SYM (__errno_location)@PLT) POP_ERRNO_LOCATION_RETURN popq %rcx + cfi_adjust_cfa_offset(-8) movl %ecx, (%rax) # endif #endif ============================================================ Index: sysdeps/x86_64/strcspn.S --- sysdeps/x86_64/strcspn.S 29 Apr 2003 22:47:18 -0000 1.2 +++ sysdeps/x86_64/strcspn.S 10 Jan 2004 16:09:41 -0000 @@ -1,7 +1,7 @@ /* strcspn (str, ss) -- Return the length of the initial segment of STR which contains no characters from SS. For AMD x86-64. - Copyright (C) 1994-1997, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1994-1997, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper . Bug fixes by Alan Modra . @@ -40,6 +40,7 @@ ENTRY (strcspn) table. */ movq %rdi, %r8 /* Save value. */ subq $256, %rsp /* Make space for 256 bytes. */ + cfi_adjust_cfa_offset(-256) movq $32, %rcx /* 32*8 bytes = 256 bytes. */ movq %rsp, %rdi xorq %rax, %rax /* We store 0s. */ @@ -110,6 +111,7 @@ L(6): incq %rax L(5): incq %rax L(4): addq $256, %rsp /* remove skipset */ + cfi_adjust_cfa_offset(-256) #if STRPBRK_P xorq %rdx,%rdx orb %cl, %cl /* was last character NUL? */ ============================================================ Index: sysdeps/x86_64/strspn.S --- sysdeps/x86_64/strspn.S 29 Apr 2003 22:47:17 -0000 1.2 +++ sysdeps/x86_64/strspn.S 10 Jan 2004 16:09:41 -0000 @@ -1,7 +1,7 @@ /* strspn (str, ss) -- Return the length of the initial segment of STR which contains only characters from SS. For AMD x86-64. - Copyright (C) 1994-1997, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1994-1997, 2000,2002,2003,2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper . Bug fixes by Alan Modra . @@ -36,6 +36,7 @@ ENTRY (strspn) table. */ movq %rdi, %r8 /* Save value. */ subq $256, %rsp /* Make space for 256 bytes. */ + cfi_adjust_cfa_offset(256) movq $32, %rcx /* 32*8 bytes = 256 bytes. */ movq %rsp, %rdi xorq %rax, %rax /* We store 0s. */ @@ -106,6 +107,7 @@ L(6): incq %rax L(5): incq %rax L(4): addq $256, %rsp /* remove stopset */ + cfi_adjust_cfa_offset(-256) subq %rdx, %rax /* we have to return the number of valid characters, so compute distance to first non-valid character */ -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From drepper@redhat.com Sat Jan 10 18:07:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 10 Jan 2004 18:07:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> Message-ID: <40003EC0.2010305@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have added the patch bu ~ there is no LinuxThreads patch ~ if you send mails signed (or any MIME mail) don't include the patches inlined. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAAD7A2ijCOnn/RHQRAlVqAKCg8Su0dQEmbsqJRXPuGRx5z/OehgCfZdXD tgpbIrtepbkwyP+wtxwZB2c= =UHEO -----END PGP SIGNATURE----- From aj@suse.de Sat Jan 10 19:22:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sat, 10 Jan 2004 19:22:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <40003EC0.2010305@redhat.com> (Ulrich Drepper's message of "Sat, 10 Jan 2004 10:04:48 -0800") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <40003EC0.2010305@redhat.com> Message-ID: Ulrich Drepper writes: > I have added the patch bu > > ~ there is no LinuxThreads patch Appended - I'll commit it myself now. > ~ if you send mails signed (or any MIME mail) don't include the patches > inlined. What exactly is the problem? Andreas ============================================================ Index: linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S --- linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S 11 Feb 2003 06:27:54 -0000 1.4 +++ linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S 10 Jan 2004 19:21:58 -0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -39,6 +39,7 @@ ENTRY (__vfork) /* Pop the return PC value into RDI. We need a register that is preserved by the syscall and that we're allowed to destroy. */ popq %rdi + cfi_adjust_cfa_offset(-8) /* Stuff the syscall number in RAX and enter into the kernel. */ movl $SYS_ify (vfork), %eax @@ -46,6 +47,7 @@ ENTRY (__vfork) /* Push back the return PC. */ pushq %rdi + cfi_adjust_cfa_offset(-7) cmpl $-4095, %eax jae SYSCALL_ERROR_LABEL /* Branch forward if it failed. */ -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N??rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 From jakub@redhat.com Sat Jan 10 19:24:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 10 Jan 2004 19:24:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <40003EC0.2010305@redhat.com> Message-ID: <20040110171740.GL6413@sunsite.ms.mff.cuni.cz> On Sat, Jan 10, 2004 at 08:22:51PM +0100, Andreas Jaeger wrote: > @@ -46,6 +47,7 @@ ENTRY (__vfork) > > /* Push back the return PC. */ > pushq %rdi > + cfi_adjust_cfa_offset(-7) You mean -8, right? Jakub From aj@suse.de Sat Jan 10 19:26:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sat, 10 Jan 2004 19:26:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040110171740.GL6413@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Sat, 10 Jan 2004 18:17:40 +0100") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <40003EC0.2010305@redhat.com> <20040110171740.GL6413@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Sat, Jan 10, 2004 at 08:22:51PM +0100, Andreas Jaeger wrote: >> @@ -46,6 +47,7 @@ ENTRY (__vfork) >> >> /* Push back the return PC. */ >> pushq %rdi >> + cfi_adjust_cfa_offset(-7) > > You mean -8, right? Yes, definitly. Thanks, will fix it directly... Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Sat Jan 10 19:27:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sat, 10 Jan 2004 19:27:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040110171740.GL6413@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Sat, 10 Jan 2004 18:17:40 +0100") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <40003EC0.2010305@redhat.com> <20040110171740.GL6413@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Sat, Jan 10, 2004 at 08:22:51PM +0100, Andreas Jaeger wrote: >> @@ -46,6 +47,7 @@ ENTRY (__vfork) >> >> /* Push back the return PC. */ >> pushq %rdi >> + cfi_adjust_cfa_offset(-7) > > You mean -8, right? +8 in fact ;-( Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From drepper@redhat.com Sat Jan 10 19:30:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 10 Jan 2004 19:30:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <40003EC0.2010305@redhat.com> Message-ID: <40005229.1020309@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Jaeger wrote: >>~ if you send mails signed (or any MIME mail) don't include the patches >>inlined. > > > What exactly is the problem? The MIME encoding of course. The body contains all these ugly =3D etc. If you use MIME, as signing enforces, use attachments. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAAFIp2ijCOnn/RHQRAoQUAJ4lvk0MfRb3IzE8KjaYqioCc3zmGwCglMpr J6Ue0EHq9ybR/NpUNHDEm2o= =FfA6 -----END PGP SIGNATURE----- From aj@suse.de Sat Jan 10 19:51:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sat, 10 Jan 2004 19:51:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: (Andreas Jaeger's message of "Sat, 10 Jan 2004 17:10:18 +0100") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> Message-ID: Andreas Jaeger writes: > Jakub Jelinek writes: > [...] >>> libc/sysdeps/x86_64/__longjmp.S > > What's the best way to handle the destroying of the registers with > CFI? Should we just mark the registers with "cfi_undefined"? I'm appending a proposed patch for __longjmp.S. Or can anybody envision a better way doing this? Andreas 2004-01-10 Andreas Jaeger * sysdeps/x86_64/__longjmp.S: Add cfi directives. ============================================================ Index: sysdeps/x86_64/__longjmp.S --- sysdeps/x86_64/__longjmp.S 19 Sep 2001 10:12:07 -0000 1.1 +++ sysdeps/x86_64/__longjmp.S 10 Jan 2004 19:47:01 -0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,11 +28,17 @@ ENTRY(__longjmp) /* Restore registers. */ movq (JB_RBX*8)(%rdi),%rbx + cfi_undefined(%rbx) movq (JB_RBP*8)(%rdi),%rbp + cfi_undefined(%rbp) movq (JB_R12*8)(%rdi),%r12 + cfi_undefined(%r12) movq (JB_R13*8)(%rdi),%r13 + cfi_undefined(%r13) movq (JB_R14*8)(%rdi),%r14 + cfi_undefined(%r14) movq (JB_R15*8)(%rdi),%r15 + cfi_undefined(%r15) /* Set return value for setjmp. */ test %esi,%esi mov $01,%eax @@ -40,5 +46,6 @@ ENTRY(__longjmp) mov %esi, %eax movq (JB_PC*8)(%rdi),%rdx movq (JB_RSP*8)(%rdi),%rsp + cfi_undefined(%rsp) jmpq *%rdx END (BP_SYM (__longjmp)) -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Sat Jan 10 19:57:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 10 Jan 2004 19:57:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> Message-ID: <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> On Sat, Jan 10, 2004 at 08:49:49PM +0100, Andreas Jaeger wrote: > Andreas Jaeger writes: > > > Jakub Jelinek writes: > > [...] > >>> libc/sysdeps/x86_64/__longjmp.S > > > > What's the best way to handle the destroying of the registers with > > CFI? Should we just mark the registers with "cfi_undefined"? > > I'm appending a proposed patch for __longjmp.S. Or can anybody > envision a better way doing this? Cannot you from the first movq ***,%rbx pretend you're already at the jmpq %*rdx instruction, ie. unwind to the longjmp target? Write in the unwind info where to fetch %rbp, %r12..%r15, ra etc. from? Jakub From aj@suse.de Sat Jan 10 20:13:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sat, 10 Jan 2004 20:13:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Sat, 10 Jan 2004 18:50:49 +0100") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Sat, Jan 10, 2004 at 08:49:49PM +0100, Andreas Jaeger wrote: >> Andreas Jaeger writes: >> >> > Jakub Jelinek writes: >> > [...] >> >>> libc/sysdeps/x86_64/__longjmp.S >> > >> > What's the best way to handle the destroying of the registers with >> > CFI? Should we just mark the registers with "cfi_undefined"? >> >> I'm appending a proposed patch for __longjmp.S. Or can anybody >> envision a better way doing this? > > Cannot you from the first movq ***,%rbx pretend you're > already at the jmpq %*rdx instruction, ie. unwind to the > longjmp target? > Write in the unwind info where to fetch %rbp, %r12..%r15, > ra etc. from? You mean something like the following? cfi_def_cfa(%rdi,0) cfi_offset(%rbx,JB_RBX*8) cfi_offset(%r12,JB_R12*8) ... I'm not sure what the right way is to handle this here at all ... Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From sjmunroe@us.ibm.com Sat Jan 10 20:31:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Sat, 10 Jan 2004 20:31:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 Message-ID: <40006121.9070903@us.ibm.com> The attached patch provides base enabling for PowerPC Altivec (AKA VMX) and for versioning effected functions. 2.6.0 kernels provide a PPC_FEATURE_HAS_ALTIVEC status in the AT_HWCAP. We need to capture this status as a static flag (__has_altivec) so functions enabled for altivec can run safely on PowerPC hardware without the Altivec feature. And now for the fun part. I think this requires a new glibc version because GLIBC_2.3.3 symbols are already defined for these (get/setcontext) functions in shipped distros. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ppcvmx-base-20040104.txt URL: From sjmunroe@us.ibm.com Sat Jan 10 21:03:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Sat, 10 Jan 2004 21:03:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 2 Message-ID: <40006880.3050400@us.ibm.com> The patch containts the *context function changes for powerpc32. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ppc32vmx-context-20040104.txt URL: From sjmunroe@us.ibm.com Sat Jan 10 21:04:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Sat, 10 Jan 2004 21:04:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 3 Message-ID: <400068CF.2010007@us.ibm.com> This patch contains the *context functions for powerpc64 -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ppc64vmx-context-20040104.txt URL: From roland@redhat.com Sat Jan 10 21:08:00 2004 From: roland@redhat.com (Roland McGrath) Date: Sat, 10 Jan 2004 21:08:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 3 In-Reply-To: Steve Munroe's message of Saturday, 10 January 2004 15:04:15 -0600 <400068CF.2010007@us.ibm.com> Message-ID: <200401102108.i0AL8oNl008500@magilla.sf.frob.com> > + GLIBC_2.3 { > + getcontext; > + setcontext; > + swapcontext; > + } This should not be necessary. From roland@redhat.com Sat Jan 10 21:11:00 2004 From: roland@redhat.com (Roland McGrath) Date: Sat, 10 Jan 2004 21:11:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 In-Reply-To: Steve Munroe's message of Saturday, 10 January 2004 14:31:29 -0600 <40006121.9070903@us.ibm.com> Message-ID: <200401102111.i0ALB5Et008518@magilla.sf.frob.com> > The attached patch provides base enabling for PowerPC Altivec (AKA VMX) > and for versioning effected functions. 2.6.0 kernels provide a > PPC_FEATURE_HAS_ALTIVEC status in the AT_HWCAP. We need to capture this > status as a static flag (__has_altivec) so functions enabled for altivec > can run safely on PowerPC hardware without the Altivec feature. Why did you introduce this variable? Using GL(dl_hwcap) should be fine. From aj@suse.de Sun Jan 11 10:40:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 10:40:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: (Andreas Jaeger's message of "Sat, 10 Jan 2004 21:13:38 +0100") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> Message-ID: Andreas Jaeger writes: > Jakub Jelinek writes: > >> On Sat, Jan 10, 2004 at 08:49:49PM +0100, Andreas Jaeger wrote: >>> Andreas Jaeger writes: >>> >>> > Jakub Jelinek writes: >>> > [...] >>> >>> libc/sysdeps/x86_64/__longjmp.S >>> > >>> > What's the best way to handle the destroying of the registers with >>> > CFI? Should we just mark the registers with "cfi_undefined"? >>> >>> I'm appending a proposed patch for __longjmp.S. Or can anybody >>> envision a better way doing this? >> >> Cannot you from the first movq ***,%rbx pretend you're >> already at the jmpq %*rdx instruction, ie. unwind to the >> longjmp target? >> Write in the unwind info where to fetch %rbp, %r12..%r15, >> ra etc. from? > > You mean something like the following? > > cfi_def_cfa(%rdi,0) > cfi_offset(%rbx,JB_RBX*8) > cfi_offset(%r12,JB_R12*8) > ... > > I'm not sure what the right way is to handle this here at all ... I've done it now completely: ENTRY(__longjmp) /* Restore registers. */ /* We add unwind information for the target here. */ cfi_def_cfa(%rdi, 0) cfi_offset(%rbx,JB_RBX*8) cfi_offset(%r12,JB_R12*8) cfi_offset(%r13,JB_R13*8) cfi_offset(%r14,JB_R14*8) cfi_offset(%r15,JB_R15*8) cfi_offset(%rsp,JB_RSP*8) movq (JB_RBX*8)(%rdi),%rbx movq (JB_RBP*8)(%rdi),%rbp movq (JB_R12*8)(%rdi),%r12 movq (JB_R13*8)(%rdi),%r13 movq (JB_R14*8)(%rdi),%r14 movq (JB_R15*8)(%rdi),%r15 /* Set return value for setjmp. */ test %esi,%esi mov $01,%eax cmove %eax,%esi mov %esi, %eax movq (JB_PC*8)(%rdi),%rdx movq (JB_RSP*8)(%rdi),%rsp jmpq *%rdx END (BP_SYM (__longjmp)) Does this look ok? In that case I'll commit it (and will fix setcontext/swapcontext in a similar way)... Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Sun Jan 11 10:50:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 10:50:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040111024737.A1431@redhat.com> (Richard Henderson's message of "Sun, 11 Jan 2004 02:47:37 -0800") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> <20040111024737.A1431@redhat.com> Message-ID: Richard Henderson writes: > On Sun, Jan 11, 2004 at 11:40:06AM +0100, Andreas Jaeger wrote: >> /* We add unwind information for the target here. */ >> cfi_def_cfa(%rdi, 0) >> cfi_offset(%rbx,JB_RBX*8) >> cfi_offset(%r12,JB_R12*8) >> cfi_offset(%r13,JB_R13*8) >> cfi_offset(%r14,JB_R14*8) >> cfi_offset(%r15,JB_R15*8) >> cfi_offset(%rsp,JB_RSP*8) > > You're missing > >> movq (JB_RBP*8)(%rdi),%rbp Right. >> movq (JB_PC*8)(%rdi),%rdx Are you sure? Do I have to do this for the PC also? Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Sun Jan 11 10:54:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 10:54:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040111025223.A2564@redhat.com> (Richard Henderson's message of "Sun, 11 Jan 2004 02:52:23 -0800") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> <20040111024737.A1431@redhat.com> <20040111025223.A2564@redhat.com> Message-ID: Richard Henderson writes: > On Sun, Jan 11, 2004 at 11:50:12AM +0100, Andreas Jaeger wrote: >> >> movq (JB_PC*8)(%rdi),%rdx >> >> Are you sure? Do I have to do this for the PC also? > > Yes. Added. We're not doing it anywhere for the program counter AFAIK. Or is this done implicitly and we have to do it here explicitly? Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Sun Jan 11 10:57:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 10:57:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: (Andreas Jaeger's message of "Sun, 11 Jan 2004 11:54:28 +0100") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> <20040111024737.A1431@redhat.com> <20040111025223.A2564@redhat.com> Message-ID: Ok, here's the complete function now: ENTRY(__longjmp) /* Restore registers. */ /* We add unwind information for the target here. */ cfi_def_cfa(%rdi, 0) cfi_offset(%rbx,JB_RBX*8) cfi_offset(%rbx,JB_RBP*8) cfi_offset(%r12,JB_R12*8) cfi_offset(%r13,JB_R13*8) cfi_offset(%r14,JB_R14*8) cfi_offset(%r15,JB_R15*8) cfi_offset(%rsp,JB_RSP*8) cfi_offset(%rip,JB_PC*8) movq (JB_RBX*8)(%rdi),%rbx movq (JB_RBP*8)(%rdi),%rbp movq (JB_R12*8)(%rdi),%r12 movq (JB_R13*8)(%rdi),%r13 movq (JB_R14*8)(%rdi),%r14 movq (JB_R15*8)(%rdi),%r15 /* Set return value for setjmp. */ test %esi,%esi mov $01,%eax cmove %eax,%esi mov %esi, %eax movq (JB_PC*8)(%rdi),%rdx movq (JB_RSP*8)(%rdi),%rsp jmpq *%rdx END (BP_SYM (__longjmp)) What do you think? Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Sun Jan 11 12:16:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 12:16:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040111030005.C13258@redhat.com> (Richard Henderson's message of "Sun, 11 Jan 2004 03:00:05 -0800") References: <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> <20040111024737.A1431@redhat.com> <20040111025223.A2564@redhat.com> <20040111030005.C13258@redhat.com> Message-ID: Richard Henderson writes: > On Sun, Jan 11, 2004 at 11:57:36AM +0100, Andreas Jaeger wrote: >> cfi_offset(%rbx,JB_RBP*8) > > Typo ^ Pasto ;-) Thanks, I'll commit the change later and will then do also swapcontext/setcontext, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Sun Jan 11 12:17:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 12:17:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040111030005.C13258@redhat.com> (Richard Henderson's message of "Sun, 11 Jan 2004 03:00:05 -0800") References: <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> <20040111024737.A1431@redhat.com> <20040111025223.A2564@redhat.com> <20040111030005.C13258@redhat.com> Message-ID: And here comes setcontext: ENTRY(__setcontext) /* Save argument since syscall will destroy it. */ pushq %rdi cfi_adjust_cfa_offset(8) /* Set the signal mask with rt_sigprocmask (SIG_SETMASK, mask, NULL, _NSIG/8). */ leaq oSIGMASK(%rdi), %rsi xorq %rdx, %rdx movq $SIG_SETMASK, %rdi movq $_NSIG8,%r10 movq $__NR_rt_sigprocmask, %rax syscall popq %rdi /* Reload %rdi, adjust stack. */ cfi_adjust_cfa_offset(-8) cmpq $-4095, %rax /* Check %rax for error. */ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */ /* Restore the floating-point context. Not the registers, only the rest. */ movq oFPREGS(%rdi), %rcx fldenv (%rcx) ldmxcsr oMXCSR(%rdi) /* Load the new stack pointer, the preserved registers and registers used for passing args. */ cfi_def_cfa(%rdi, 0) cfi_offset(%rbx,oRBX) cfi_offset(%rbp,oRBP) cfi_offset(%r12,oR12) cfi_offset(%r13,oR13) cfi_offset(%r14,oR14) cfi_offset(%r15,oR15) cfi_offset(%rsp,oRSP) cfi_offset(%rip,oRIP) movq oRSP(%rdi), %rsp movq oRBX(%rdi), %rbx movq oRBP(%rdi), %rbp movq oR12(%rdi), %r12 movq oR13(%rdi), %r13 movq oR14(%rdi), %r14 movq oR15(%rdi), %r15 /* The following ret should return to the address set with getcontext. Therefore push the address on the stack. */ movq oRIP(%rdi), %rcx pushq %rcx cfi_adjust_cfa_offset(8) movq oRSI(%rdi), %rsi movq oRDX(%rdi), %rdx movq oRCX(%rdi), %rcx movq oR8(%rdi), %r8 movq oR9(%rdi), %r9 /* Setup finally %rdi. */ movq oRDI(%rdi), %rdi /* We changed %rdi, fix cfi. */ cfi_def_cfa(%rsp, 0) cfi_same_value(%rbx) cfi_same_value(%rbp) cfi_same_value(%r12) cfi_same_value(%r13) cfi_same_value(%r14) cfi_same_value(%r15) /* Clear rax to indicate success. */ xorq %rax, %rax L(pseudo_end): ret PSEUDO_END(__setcontext) Does it look sane? Btw. cfi_same_value is not yet defined in sysdeps.h and needs to be defined with the appended patch. Is it ok to commit that one? Andreas 2004-01-11 Andreas Jaeger * sysdeps/generic/sysdep.h (CFI_SAME_VALUE): New. (cfi_same_value): New. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: libc-diff URL: -------------- next part -------------- -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From sjmunroe@us.ibm.com Sun Jan 11 16:41:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Sun, 11 Jan 2004 16:41:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 Message-ID: Roland McGrath writes: > > The attached patch provides base enabling for PowerPC Altivec (AKA VMX) > > and for versioning effected functions. 2.6.0 kernels provide a > > PPC_FEATURE_HAS_ALTIVEC status in the AT_HWCAP. We need to capture this > > status as a static flag (__has_altivec) so functions enabled for altivec > > can run safely on PowerPC hardware without the Altivec feature. > > Why did you introduce this variable? Using GL(dl_hwcap) should be fine. GL(dl_hwcap) is not very asm friendly. ldsodefs.h is full of things that gas does not like. Plus in the shared case _rtld_global.dl_hwcap is a struct/field and there is no (automatic/correct) way to obtain the offset of the dl_hwcap field for the asm code. Steven J. Munroe Power Linux Toolchain Architect IBM Corporation, Linux Technology Center From aj@suse.de Sun Jan 11 17:32:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 17:32:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 In-Reply-To: <40006121.9070903@us.ibm.com> (Steve Munroe's message of "Sat, 10 Jan 2004 14:31:29 -0600") References: <40006121.9070903@us.ibm.com> Message-ID: Steve Munroe writes: > +/* from linux/asm/cputable.h. */ > +#define PPC_FEATURE_32 0x80000000 > +#define PPC_FEATURE_64 0x40000000 > +#define PPC_FEATURE_601_INSTR 0x20000000 > +#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 > +#define PPC_FEATURE_HAS_FPU 0x08000000 > +#define PPC_FEATURE_HAS_MMU 0x04000000 > +#define PPC_FEATURE_HAS_4xxMAC 0x02000000 > +#define PPC_FEATURE_UNIFIED_CACHE 0x01000000 Please add comments here. > +#ifndef SHARED > + __has_altivec=((GL(dl_hwcap) & PPC_FEATURE_HAS_ALTIVEC) ? 1:0); According to the GNU Coding standards this should have some more whitespace, e.g.: __has_altivec = ((GL (dl_hwcap) & PPC_FEATURE_HAS_ALTIVEC) ? 1 : 0); Please rewrite your patch to follow the Coding standards everywhere... > +#endif > return generic_start_main (stinfo->main, argc, ubp_av, auxvec, > stinfo->init, stinfo->fini, rtld_fini, > stack_on_entry); > diff -urN libc23-cvstip-20040102/sysdeps/powerpc/longjmp.c libc23/sysdeps/powerpc/longjmp.c > --- libc23-cvstip-20040102/sysdeps/powerpc/longjmp.c Wed Dec 31 18:00:00 1969 > +++ libc23/sysdeps/powerpc/longjmp.c Sat Jan 10 11:29:58 2004 > @@ -0,0 +1,56 @@ > +/* Copyright (C) 1991,92,94,95,97,98,2000,2002 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, write to the Free > + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > + 02111-1307 USA. */ > +/* > + Versioned copy of sysdeps/generic/longjmp.c modified for altivec support. > + */ This is not a properly formatted comment. > +#include > +#include Just one space everywhere. > +#include > +#include > + > +#if defined(NOT_IN_libc) || !defined(SHARED) > +/* We don't want this variable both in ld.so & libc.so as > + we would then have duplicate variable linker confusion. */ > +int vec__has_altivec=0; > +default_symbol_version (vec__has_altivec,__has_altivec,GLIBC_2.3.4); > [...] Missing whitespace again. Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From drepper@redhat.com Sun Jan 11 18:21:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 11 Jan 2004 18:21:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 In-Reply-To: References: Message-ID: <4001937A.5070604@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Steve Munroe wrote: > GL(dl_hwcap) is not very asm friendly. And the problem is? Automatically define a symbol with the offset in the struct. This is done similarly in several places. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAAZN/2ijCOnn/RHQRAtZuAJ0eiX7BgfSO4m5QWXq1jLFr4WpOnQCfSsUS weUVMOkfa+s7D2ZZScbXaDY= =cKRg -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Sun Jan 11 18:45:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Sun, 11 Jan 2004 18:45:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 Message-ID: Ulrich Drepper wrote: > Steve Munroe wrote: > > > GL(dl_hwcap) is not very asm friendly. > > And the problem is? Automatically define a symbol with the offset > in the struct. This is done similarly in several places. You mean like ./libc23/nptl/sysdeps/powerpc/tcb-offsets.sym. This works because the tcb is defined in tls.h. But struct rtld_global is defined inline in rtld.c! Can this stuct be moved to a header? Seems like with the initialization and the #include dl-procinfo.c this would ripple across several arches. Steven J. Munroe Power Linux Toolchain Architect IBM Corporation, Linux Technology Center From jakub@redhat.com Sun Jan 11 18:50:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 11 Jan 2004 18:50:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: References: <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> <20040111024737.A1431@redhat.com> <20040111025223.A2564@redhat.com> <20040111030005.C13258@redhat.com> Message-ID: <20040111164256.GN6413@sunsite.ms.mff.cuni.cz> On Sun, Jan 11, 2004 at 01:17:52PM +0100, Andreas Jaeger wrote: > /* Load the new stack pointer, the preserved registers and > registers used for passing args. */ > cfi_def_cfa(%rdi, 0) > cfi_offset(%rbx,oRBX) > cfi_offset(%rbp,oRBP) > cfi_offset(%r12,oR12) > cfi_offset(%r13,oR13) > cfi_offset(%r14,oR14) > cfi_offset(%r15,oR15) > cfi_offset(%rsp,oRSP) > cfi_offset(%rip,oRIP) > > movq oRSP(%rdi), %rsp > movq oRBX(%rdi), %rbx > movq oRBP(%rdi), %rbp > movq oR12(%rdi), %r12 > movq oR13(%rdi), %r13 > movq oR14(%rdi), %r14 > movq oR15(%rdi), %r15 > > /* The following ret should return to the address set with > getcontext. Therefore push the address on the stack. */ > movq oRIP(%rdi), %rcx > pushq %rcx > cfi_adjust_cfa_offset(8) pushq %rcx modifies %rsp, but current CFI here is %rdi which is unchanged. Jakub From jakub@redhat.com Sun Jan 11 18:52:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 11 Jan 2004 18:52:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 In-Reply-To: References: Message-ID: <20040111164513.GO6413@sunsite.ms.mff.cuni.cz> On Sun, Jan 11, 2004 at 12:45:16PM -0600, Steve Munroe wrote: > Ulrich Drepper wrote: > > > Steve Munroe wrote: > > > > > GL(dl_hwcap) is not very asm friendly. > > > > And the problem is? Automatically define a symbol with the offset > > in the struct. This is done similarly in several places. > > You mean like ./libc23/nptl/sysdeps/powerpc/tcb-offsets.sym. This works > because the tcb is defined in tls.h. But struct rtld_global is defined > inline in rtld.c! Can this stuct be moved to a header? Seems like with the > initialization and the #include dl-procinfo.c this would ripple across > several arches. The type struct rtld_global is defined in , not rtld.c. Jakub From aj@suse.de Sun Jan 11 19:28:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 19:28:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040111164256.GN6413@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Sun, 11 Jan 2004 17:42:56 +0100") References: <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> <20040111024737.A1431@redhat.com> <20040111025223.A2564@redhat.com> <20040111030005.C13258@redhat.com> <20040111164256.GN6413@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Sun, Jan 11, 2004 at 01:17:52PM +0100, Andreas Jaeger wrote: >> /* Load the new stack pointer, the preserved registers and >> registers used for passing args. */ >> cfi_def_cfa(%rdi, 0) >> cfi_offset(%rbx,oRBX) >> cfi_offset(%rbp,oRBP) >> cfi_offset(%r12,oR12) >> cfi_offset(%r13,oR13) >> cfi_offset(%r14,oR14) >> cfi_offset(%r15,oR15) >> cfi_offset(%rsp,oRSP) >> cfi_offset(%rip,oRIP) >> >> movq oRSP(%rdi), %rsp >> movq oRBX(%rdi), %rbx >> movq oRBP(%rdi), %rbp >> movq oR12(%rdi), %r12 >> movq oR13(%rdi), %r13 >> movq oR14(%rdi), %r14 >> movq oR15(%rdi), %r15 >> >> /* The following ret should return to the address set with >> getcontext. Therefore push the address on the stack. */ >> movq oRIP(%rdi), %rcx >> pushq %rcx >> cfi_adjust_cfa_offset(8) > > pushq %rcx modifies %rsp, but current CFI here is %rdi > which is unchanged. Thanks! I'll commit with that change once I get approval for the sysdeps/generic/sysdep.h change... Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Sun Jan 11 20:13:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 11 Jan 2004 20:13:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: References: <20040111024737.A1431@redhat.com> <20040111025223.A2564@redhat.com> <20040111030005.C13258@redhat.com> <20040111164256.GN6413@sunsite.ms.mff.cuni.cz> Message-ID: <20040111180632.GR6413@sunsite.ms.mff.cuni.cz> On Sun, Jan 11, 2004 at 08:28:37PM +0100, Andreas Jaeger wrote: > Thanks! I'll commit with that change once I get approval for the > sysdeps/generic/sysdep.h change... Have you tested it? E.g. for longjmp program with 2 threads, one pthread_kill'ing the other one with some signal randomly and the other doing setjmp/longjmp in a tight loop and checking in the signal handler if the address is inside of __longjmp and if so, trying to do e.g. backtrace or some other _Unwind_* function. Jakub From aj@suse.de Sun Jan 11 20:19:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 20:19:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040111180632.GR6413@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Sun, 11 Jan 2004 19:06:32 +0100") References: <20040111024737.A1431@redhat.com> <20040111025223.A2564@redhat.com> <20040111030005.C13258@redhat.com> <20040111164256.GN6413@sunsite.ms.mff.cuni.cz> <20040111180632.GR6413@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Sun, Jan 11, 2004 at 08:28:37PM +0100, Andreas Jaeger wrote: >> Thanks! I'll commit with that change once I get approval for the >> sysdeps/generic/sysdep.h change... > > Have you tested it? > E.g. for longjmp program with 2 threads, one pthread_kill'ing the other > one with some signal randomly and the other doing setjmp/longjmp in a tight > loop and checking in the signal handler if the address is inside of > __longjmp and if so, trying to do e.g. backtrace or some other _Unwind_* > function. No, I haven't done anything like that... Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Sun Jan 11 20:31:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 11 Jan 2004 20:31:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040111202020.GB24540@redhat.com> (Richard Henderson's message of "Sun, 11 Jan 2004 12:20:20 -0800") References: <20040110175049.GM6413@sunsite.ms.mff.cuni.cz> <20040111024737.A1431@redhat.com> <20040111025223.A2564@redhat.com> <20040111030005.C13258@redhat.com> <20040111202020.GB24540@redhat.com> Message-ID: Richard Henderson writes: > On Sun, Jan 11, 2004 at 01:17:52PM +0100, Andreas Jaeger wrote: >> pushq %rcx >> cfi_adjust_cfa_offset(8) > > Jakub already pointed out that this is wrong. > >> /* We changed %rdi, fix cfi. */ >> cfi_def_cfa(%rsp, 0) > > But the push means this is wrong too -- the CFA is rsp+8. > > Also wrong at this point is the return address. The value > is now stored at CFA-8, where we pushed it above. This would give the following routine: ENTRY(__setcontext) /* Save argument since syscall will destroy it. */ pushq %rdi cfi_adjust_cfa_offset(8) /* Set the signal mask with rt_sigprocmask (SIG_SETMASK, mask, NULL, _NSIG/8). */ leaq oSIGMASK(%rdi), %rsi xorq %rdx, %rdx movq $SIG_SETMASK, %rdi movq $_NSIG8,%r10 movq $__NR_rt_sigprocmask, %rax syscall popq %rdi /* Reload %rdi, adjust stack. */ cfi_adjust_cfa_offset(-8) cmpq $-4095, %rax /* Check %rax for error. */ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */ /* Restore the floating-point context. Not the registers, only the rest. */ movq oFPREGS(%rdi), %rcx fldenv (%rcx) ldmxcsr oMXCSR(%rdi) /* Load the new stack pointer, the preserved registers and registers used for passing args. */ cfi_def_cfa(%rdi, 0) cfi_offset(%rbx,oRBX) cfi_offset(%rbp,oRBP) cfi_offset(%r12,oR12) cfi_offset(%r13,oR13) cfi_offset(%r14,oR14) cfi_offset(%r15,oR15) cfi_offset(%rsp,oRSP) cfi_offset(%rip,oRIP) movq oRSP(%rdi), %rsp movq oRBX(%rdi), %rbx movq oRBP(%rdi), %rbp movq oR12(%rdi), %r12 movq oR13(%rdi), %r13 movq oR14(%rdi), %r14 movq oR15(%rdi), %r15 /* The following ret should return to the address set with getcontext. Therefore push the address on the stack. */ movq oRIP(%rdi), %rcx pushq %rcx movq oRSI(%rdi), %rsi movq oRDX(%rdi), %rdx movq oRCX(%rdi), %rcx movq oR8(%rdi), %r8 movq oR9(%rdi), %r9 /* Setup finally %rdi. */ movq oRDI(%rdi), %rdi /* We changed %rdi, fix cfi. */ cfi_def_cfa(%rsp, 8) cfi_same_value(%rbx) cfi_same_value(%rbp) cfi_same_value(%r12) cfi_same_value(%r13) cfi_same_value(%r14) cfi_same_value(%r15) cfi_offset(%rip,-8) /* Clear rax to indicate success. */ xorq %rax, %rax Thanks, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Mon Jan 12 09:58:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 12 Jan 2004 09:58:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> Message-ID: <20040112075135.GT6413@sunsite.ms.mff.cuni.cz> On Sat, Jan 10, 2004 at 05:10:18PM +0100, Andreas Jaeger wrote: > --- sysdeps/unix/sysv/linux/x86_64/__start_context.S 27 Aug 2003 23:03:41 -0000 1.2 > +++ sysdeps/unix/sysv/linux/x86_64/__start_context.S 10 Jan 2004 16:09:40 -0000 > @@ -1,4 +1,4 @@ > -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. > +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. > This file is part of the GNU C Library. > Contributed by Andreas Jaeger , 2002. > > @@ -33,6 +33,7 @@ ENTRY(__start_context) > movq %rbx, %rsp This is not reflected in the unwind info. Unless %rbx points to a populated stack with correct caller something needs to be done about it. > --- sysdeps/x86_64/strcspn.S 29 Apr 2003 22:47:18 -0000 1.2 > +++ sysdeps/x86_64/strcspn.S 10 Jan 2004 16:09:41 -0000 > @@ -1,7 +1,7 @@ > /* strcspn (str, ss) -- Return the length of the initial segment of STR > which contains no characters from SS. > For AMD x86-64. > - Copyright (C) 1994-1997, 2000, 2002, 2003 Free Software Foundation, Inc. > + Copyright (C) 1994-1997, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. > This file is part of the GNU C Library. > Contributed by Ulrich Drepper . > Bug fixes by Alan Modra . > @@ -40,6 +40,7 @@ ENTRY (strcspn) > table. */ > movq %rdi, %r8 /* Save value. */ > subq $256, %rsp /* Make space for 256 bytes. */ > + cfi_adjust_cfa_offset(-256) Typo/pasto. Jakub From aj@suse.de Mon Jan 12 16:44:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Mon, 12 Jan 2004 16:44:00 -0000 Subject: [PATCH] Fix AMD64 backtrace In-Reply-To: <20040112075135.GT6413@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Mon, 12 Jan 2004 08:51:35 +0100") References: <20040108134216.GE6413@sunsite.ms.mff.cuni.cz> <20040112075135.GT6413@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Sat, Jan 10, 2004 at 05:10:18PM +0100, Andreas Jaeger wrote: >> --- sysdeps/unix/sysv/linux/x86_64/__start_context.S 27 Aug 2003 23:03:41 -0000 1.2 >> +++ sysdeps/unix/sysv/linux/x86_64/__start_context.S 10 Jan 2004 16:09:40 -0000 >> @@ -1,4 +1,4 @@ >> -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. >> +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. >> This file is part of the GNU C Library. >> Contributed by Andreas Jaeger , 2002. >> >> @@ -33,6 +33,7 @@ ENTRY(__start_context) >> movq %rbx, %rsp > > This is not reflected in the unwind info. > Unless %rbx points to a populated stack with correct caller > something needs to be done about it. It should point to a populated stack: /* This removes the parameters passed to the function given to 'makecontext' from the stack. RBX contains the address on the stack pointer for the next context. */ But yeah, we destroy %rsp - so what can we do here? > >> --- sysdeps/x86_64/strcspn.S 29 Apr 2003 22:47:18 -0000 1.2 >> +++ sysdeps/x86_64/strcspn.S 10 Jan 2004 16:09:41 -0000 >> @@ -1,7 +1,7 @@ >> /* strcspn (str, ss) -- Return the length of the initial segment of STR >> which contains no characters from SS. >> For AMD x86-64. >> - Copyright (C) 1994-1997, 2000, 2002, 2003 Free Software Foundation, Inc. >> + Copyright (C) 1994-1997, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. >> This file is part of the GNU C Library. >> Contributed by Ulrich Drepper . >> Bug fixes by Alan Modra . >> @@ -40,6 +40,7 @@ ENTRY (strcspn) >> table. */ >> movq %rdi, %r8 /* Save value. */ >> subq $256, %rsp /* Make space for 256 bytes. */ >> + cfi_adjust_cfa_offset(-256) > > Typo/pasto. Fixed and committed - thanks, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From sjmunroe@us.ibm.com Tue Jan 13 01:13:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Tue, 13 Jan 2004 01:13:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 revision a Message-ID: <40034614.7070005@us.ibm.com> Reissue of this patch. Changed to use _dl_hwcap directly and eliminate __has_altivec. This simplified the versioning but requires a rtld-global-offsets.sym file to get the _dl_hwcap field offset. Also moved the PPC_FEATURES from elf.h to powerpc/sysdeps.h which is a better place for them (easier for asm code). -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ppcvmx-base-20040104.txt URL: From sjmunroe@us.ibm.com Tue Jan 13 01:15:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Tue, 13 Jan 2004 01:15:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 2, revision a Message-ID: <400346BD.9080804@us.ibm.com> Reissue of the PPC32 get/setcontext changes for Altivec with changess to use _dl_hwcap directly. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ppc32vmx-context-20040104.txt URL: From sjmunroe@us.ibm.com Tue Jan 13 01:18:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Tue, 13 Jan 2004 01:18:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 3 revision a Message-ID: <4003476F.4010406@us.ibm.com> Reissue of the PPC64 get/setcontext changes for Altivec with changes to use _dl_hwcap directly. Plus eliminated unecessary Version changes. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ppc64vmx-context-20040104.txt URL: From drepper@redhat.com Tue Jan 13 08:38:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 13 Jan 2004 08:38:00 -0000 Subject: PT_GNU_RELRO support Message-ID: <4003ADC2.2030700@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've checked in the necessary support code. It's so far only tested on x86 since I had some problems with ld on other archs. This shouldn't cause any problems, though, the protection is simply not performed. Anyway, no need to do anything if the code fails on x86-64 or ia64, I'll get to testing it in the next day or two. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAA63C2ijCOnn/RHQRAqcCAJ42xKo7OBGPZj5Bx2/mCp9e0baqOgCeI5Fj NQbN4Fkx1/cJ7gWrscuY5CU= =ZHAT -----END PGP SIGNATURE----- From jakub@redhat.com Tue Jan 13 23:29:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 13 Jan 2004 23:29:00 -0000 Subject: [PATCH] Fix regex from reading uninitialized memory Message-ID: <20040113212206.GD6413@sunsite.ms.mff.cuni.cz> Hi! 2004-01-14 Jakub Jelinek * posix/regcomp.c (peek_token_bracket): Check remaining string length before re_string_peek_byte (x, 1). (parse_bracket_symbol): Likewise. * posix/regex_internal.h (re_string_is_single_byte_char): Return true at last byte in the string. * posix/bug-regex22.c (main): Add new test. --- libc/posix/regcomp.c.jj 2004-01-12 10:52:38.000000000 +0100 +++ libc/posix/regcomp.c 2004-01-14 00:16:17.000000000 +0100 @@ -1881,7 +1881,8 @@ peek_token_bracket (token, input, syntax } #endif /* RE_ENABLE_I18N */ - if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)) + if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) + && re_string_cur_idx (input) + 1 < re_string_length (input)) { /* In this case, '\' escape a character. */ unsigned char c2; @@ -1895,7 +1896,10 @@ peek_token_bracket (token, input, syntax { unsigned char c2; int token_len; - c2 = re_string_peek_byte (input, 1); + if (re_string_cur_idx (input) + 1 < re_string_length (input)) + c2 = re_string_peek_byte (input, 1); + else + c2 = 0; token->opr.c = c2; token_len = 2; switch (c2) @@ -3268,14 +3272,18 @@ parse_bracket_symbol (elem, regexp, toke { unsigned char ch, delim = token->opr.c; int i = 0; + if (re_string_eoi(regexp)) + return REG_EBRACK; for (;; ++i) { - if (re_string_eoi(regexp) || i >= BRACKET_NAME_BUF_SIZE) + if (i >= BRACKET_NAME_BUF_SIZE) return REG_EBRACK; if (token->type == OP_OPEN_CHAR_CLASS) ch = re_string_fetch_byte_case (regexp); else ch = re_string_fetch_byte (regexp); + if (re_string_eoi(regexp)) + return REG_EBRACK; if (ch == delim && re_string_peek_byte (regexp, 0) == ']') break; elem->opr.name[i] = ch; --- libc/posix/regex_internal.h.jj 2004-01-12 10:52:38.000000000 +0100 +++ libc/posix/regex_internal.h 2004-01-14 00:18:48.000000000 +0100 @@ -408,7 +408,7 @@ static unsigned char re_string_fetch_byt #define re_string_first_byte(pstr, idx) \ ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF) #define re_string_is_single_byte_char(pstr, idx) \ - ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) \ + ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \ || (pstr)->wcs[(idx) + 1] != WEOF)) #define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx) #define re_string_cur_idx(pstr) ((pstr)->cur_idx) --- libc/posix/bug-regex22.c.jj 2004-01-06 23:00:49.000000000 +0100 +++ libc/posix/bug-regex22.c 2004-01-14 00:19:52.000000000 +0100 @@ -97,6 +97,16 @@ main (void) memset (&re, 0, sizeof (re)); re.translate = trans; + s = re_compile_pattern ("[[:DIGIT:]]", 11, &re); + if (s == NULL) + { + printf ("compilation of \"[[:DIGIT:]]\" pattern unexpectedly succeeded: %s\n", + s); + result = 1; + } + + memset (&re, 0, sizeof (re)); + re.translate = trans; s = re_compile_pattern ("[[:DIGIT:]]", 2, &re); if (s == NULL) { Jakub From drepper@redhat.com Wed Jan 14 01:45:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 14 Jan 2004 01:45:00 -0000 Subject: [PATCH] Fix regex from reading uninitialized memory In-Reply-To: <20040113212206.GD6413@sunsite.ms.mff.cuni.cz> References: <20040113212206.GD6413@sunsite.ms.mff.cuni.cz> Message-ID: <40049E7E.2070209@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jakub Jelinek wrote: > * posix/regcomp.c (peek_token_bracket): Check remaining > string length before re_string_peek_byte (x, 1). > (parse_bracket_symbol): Likewise. > * posix/regex_internal.h (re_string_is_single_byte_char): Return > true at last byte in the string. > * posix/bug-regex22.c (main): Add new test. Applied. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFABJ5+2ijCOnn/RHQRAtTdAJ4wVN40O5++i+Wlv4zNn5BhGsUeXwCfQ8oq 32Ku/ymoshH6kgIMXRnG8T8= =/2/U -----END PGP SIGNATURE----- From davidm@napali.hpl.hp.com Wed Jan 14 02:58:00 2004 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Wed, 14 Jan 2004 02:58:00 -0000 Subject: more libunwind startup-overhead tuning In-Reply-To: <16357.19587.585585.513769@napali.hpl.hp.com> References: <20031218150528.GB12344@sunsite.ms.mff.cuni.cz> <16353.61411.949110.950531@napali.hpl.hp.com> <20031218202444.GC24876@devserv.devel.redhat.com> <16357.19587.585585.513769@napali.hpl.hp.com> Message-ID: <16388.45145.964001.994402@napali.hpl.hp.com> >>>>> On Sat, 20 Dec 2003 23:32:19 -0800, David Mosberger said: David> The dynamic relocation count is now down from 747 to 142 (50 David> of them are NONE relocs). David> I'm sure there is more tuning that can be done to minimize David> load-time overhead, but i'll look into those after finishing David> the DWARF unwinder. I figured a way to split the local-only unwinder into a separate library in a way that won't create API/ABI-incompatibilities (except for rather esoteric corner-cases, which won't affect GCC, GDB, or other major libunwind-users). With a separate local-only libunwind.so, the dynamic relocation count shrinks to 72 (32 of which are NONE relocs). If I use LD_DEBUG=statistics, I get the following dynamic reloc counts ("final number of relocations"): no-op program without libunwind: 90 no-op program with libunwind v0.96: 112 no-op program with separate, local-only libunwind: 93 To measure actual execution-time impact, I created a no-op program "empty" whose main() function returns immediately. Then I created a statically-linked "forker" program which spawns "empty" 10000 times. I used LD_PRELOAD to add a dependency on libunwind as desired. The results are below (numbers are execution time in seconds, as reported by "time"): real user system no-op program without libunwind: 7.347 2.401 4.940 no-op program with libunwind v0.96: 8.253 2.858 5.345 no-op program with separate, local-only libunwind: 7.878 2.627 5.250 So, with the local-only version of libunwind, the pretty much absolute worst case overhead of always linking dynamically against libunwind seems to be about 7%. Remember: this is a worst-case which applies only for shared objects which do not link against anything other than ld.so and libc.so. In my opinion, this is a reasonably small overhead (if you really want minimal startup-times for such tiny programs, static linking will give much better results anyhow). For completeness, I attached the profile for the "no libunwind" and the "local-only libunwind" cases below. The caveat for the profiles is that they cover all 10,000 invocations of "empty" and that the call-counts where obtained via sampling, so they're not 100% accurate. Even so, you can see that the call counts are sensible. For example, in the no-libunwind-case, _dl_relocate_object() gets called about 3 times per "empty" invocation (main program, ld.so, libc, I think) and about 4 times for the libunwind-case. I think the only way to essentially eliminate the overhead alltogether would be to use the analogous scheme to the one used in libpthread. That is, provide stub-versions of _Unwind_*() which, when invoked, will dlopen() libunwind.so and re-direct the calls to the appropriate entry-points in libunwind.so. However, to avoid a dependency against -ldl (which would defeat the entire purpose of the stubs), libgcc would have to use __libc_dlopen_mode(), which is probably undesirable. Comments/feedback welcome. --david Profile without libunwind.so: Each histogram sample counts as 533.125u seconds % time self cumul calls self/call tot/call name 35.38 7.94 7.94 322k 24.7u 25.7u _dl_relocate_object 16.46 3.69 11.64 66.3M 55.7n 81.6n _dl_make_fptr 10.89 2.45 14.08 8.99M 272n 467n do_lookup_versioned 7.57 1.70 15.78 41.2M 41.2n 41.2n make_fdesc 4.80 1.08 16.86 42.5M 25.4n 25.4n ld-2.3.2.so:strcmp 4.25 0.95 17.81 21.8M 43.8n 43.8n ld-2.3.2.so:__umoddi3 3.20 0.72 18.53 9.89M 72.8n 72.8n ld-2.3.2.so:_dl_elf_hash 2.55 0.57 19.11 105k 5.44u 97.6u ld-2.3.2.so:_dl_start 2.06 0.46 19.57 8.99M 51.5n 592n _dl_lookup_versioned_symbol 1.25 0.28 19.85 870k 322n 322n do_lookup 1.19 0.27 20.12 195k 1.37u 2.16u _dl_map_object_from_fd 0.87 0.20 20.31 103k 1.90u 91.6u dl_main Profile when pre-loading separate, local-only libunwind.so: % time self cumul calls self/call tot/call name 32.61 8.21 8.21 445k 18.5u 19.4u _dl_relocate_object 14.91 3.76 11.97 67.6M 55.6n 81.6n _dl_make_fptr 13.01 3.28 15.25 9.39M 349n 596n do_lookup_versioned 6.86 1.73 16.97 42.1M 41.0n 41.0n make_fdesc 5.72 1.44 18.41 32.9M 43.7n 43.7n ld-2.3.2.so:__umoddi3 5.06 1.27 19.69 56.5M 22.5n 22.5n ld-2.3.2.so:strcmp 3.24 0.81 20.50 10.4M 78.7n 78.7n ld-2.3.2.so:_dl_elf_hash 2.30 0.58 21.08 99.5k 5.83u 111u ld-2.3.2.so:_dl_start 2.00 0.50 21.59 9.43M 53.4n 725n _dl_lookup_versioned_symbol 1.43 0.36 21.95 296k 1.22u 2.05u _dl_map_object_from_fd 1.41 0.35 22.30 879k 404n 404n do_lookup 0.87 0.22 22.52 88.0k 2.47u 116u dl_main From drepper@redhat.com Wed Jan 14 05:19:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 14 Jan 2004 05:19:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 revision a In-Reply-To: <40034614.7070005@us.ibm.com> References: <40034614.7070005@us.ibm.com> Message-ID: <4004D0C4.2090001@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Steve Munroe wrote: > +++ libc23/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h 2004-01-12 18:14:28.028147584 -0600 > @@ -1,4 +1,4 @@ > -/* Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc. > +/* Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or > @@ -20,6 +20,7 @@ > #define _SYS_UCONTEXT_H 1 > > #include > +#include > #include > > /* We need the signal context definitions even if they are not used > @@ -29,7 +30,7 @@ > #if __WORDSIZE == 32 > > /* Number of general registers. */ > -#define NGREG 48 > +# define NGREG 48 > > /* Container for all general registers. */ > typedef unsigned long gregset_t[NGREG]; > @@ -62,8 +63,53 @@ > > #else > > -/* For 64-bit, a machine context is exactly a sigcontext. */ > +# ifdef __ASSUME_ALTIVEC_SIGCONTEXT This is bogus. kernel-features.h is available for compiling glibc and is not installed. You simply cannot have such a construct in a public header. The definitions must be usable regardless of the kernel used. > +struct vmx_sigcontext { > + unsigned long _unused[4]; > + int signal; > + int _pad0; > + unsigned long handler; > + unsigned long oldmask; > + struct pt_regs *regs; > + elf_gregset_t gp_regs; > + elf_fpregset_t fp_regs; Namespace violations. I know we already have some, but this doesn't mean we add more. is a standard header, look at POSIX to see what prefixes/suffixes are reserved. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFABNDE2ijCOnn/RHQRAjKqAJ0bz6cJIIc4/ISMOdxvVCgiNPcG3gCfenmj m/qF2p/AQB5wZqRxFN0vBmU= =crhV -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Thu Jan 15 02:09:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Thu, 15 Jan 2004 02:09:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 1 revision b Message-ID: <4005F648.3060603@us.ibm.com> Ulrich Drepper wrote: > This is bogus. kernel-features.h is available for compiling glibc and > is not installed. You simply cannot have such a construct in a public > header. The definitions must be usable regardless of the kernel used. Your right. cleaned up and represented. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ppcvmx-base-20040114.txt URL: From sjmunroe@us.ibm.com Thu Jan 15 02:36:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Thu, 15 Jan 2004 02:36:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 3 revision b Message-ID: <4005FC8A.6050102@us.ibm.com> Update includes some code fixes over make check failures found in revision a. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ppc64vmc-context-20040114.txt URL: From drepper@redhat.com Fri Jan 16 04:51:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 16 Jan 2004 04:51:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 3 revision b In-Reply-To: <4005FC8A.6050102@us.ibm.com> References: <4005FC8A.6050102@us.ibm.com> Message-ID: <40076CFD.2000007@redhat.com> I've applied the patches. Responsibility for any breakage they might cause is still yours. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From kukuk@suse.de Fri Jan 16 07:30:00 2004 From: kukuk@suse.de (Thorsten Kukuk) Date: Fri, 16 Jan 2004 07:30:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 3 revision b In-Reply-To: <40076CFD.2000007@redhat.com> References: <4005FC8A.6050102@us.ibm.com> <40076CFD.2000007@redhat.com> Message-ID: <20040116073039.GA4465@suse.de> On Thu, Jan 15, Ulrich Drepper wrote: > I've applied the patches. Responsibility for any breakage they might > cause is still yours. It does not compile on PPC nor PPC64: version GLIBC_2.3.4 not defined for libc Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE Linux AG Maxfeldstr. 5 D-90409 Nuernberg -------------------------------------------------------------------- Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B From sjmunroe@us.ibm.com Fri Jan 16 16:39:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Fri, 16 Jan 2004 16:39:00 -0000 Subject: [PATCH] PPC enable Alitvec hardware, part 3 revision b Message-ID: Yes this is a conundrum. These changes are changing the ABI so must be versioned but 2.3.3 is already shipped in a distro. [sjmunroe@spokane3 sjmunroe]$ uname -a Linux spokane3 2.4.21-3.EL #1 SMP Fri Sep 19 13:58:23 EDT 2003 ppc64 ppc64 ppc64 GNU/Linux [sjmunroe@spokane3 sjmunroe]$ readelf -a /lib/libc.so.6 | grep getcontext 1652: 00046e4c 8 FUNC GLOBAL DEFAULT 10 getcontext@GLIBC_2.1 2044: 00046ce4 360 FUNC GLOBAL DEFAULT 10 getcontext@@GLIBC_2.3.3 5130: 00046ce4 360 FUNC LOCAL DEFAULT 10 __getcontext 5742: 00046e4c 8 FUNC LOCAL DEFAULT 10 __getcontext_stub 7860: 00046e4c 8 FUNC GLOBAL DEFAULT 10 getcontext@GLIBC_2.1 8252: 00046ce4 360 FUNC GLOBAL DEFAULT 10 getcontext@@GLIBC_2.3.3 So these changes must be against 2.3.4 Steven J. Munroe Power Linux Toolchain Architect IBM Corporation, Linux Technology Center Thorsten Kukuk Sent by: libc-hacker-owner@sources.redhat.com 01/16/2004 01:30 AM To: libc-hacker@sources.redhat.com cc: Subject: Re: [PATCH] PPC enable Alitvec hardware, part 3 revision b On Thu, Jan 15, Ulrich Drepper wrote: > I've applied the patches. Responsibility for any breakage they might > cause is still yours. It does not compile on PPC nor PPC64: version GLIBC_2.3.4 not defined for libc Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE Linux AG Maxfeldstr. 5 D-90409 Nuernberg -------------------------------------------------------------------- Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B From roland@redhat.com Sat Jan 17 00:57:00 2004 From: roland@redhat.com (Roland McGrath) Date: Sat, 17 Jan 2004 00:57:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: David Mosberger's message of Monday, 12 January 2004 14:56:27 -0800 <16387.9755.753294.37588@napali.hpl.hp.com> Message-ID: <200401170057.i0H0vQag022225@magilla.sf.frob.com> > >> Would it be possible to add two atomic counters, > >> dl_load_additions and dl_load_removals, which would get > >> incremented whenever something is a phdr is added to/removed from > >> the list that is traversed by dl_iterate_phdr()? > > Roland> What interface do you propose for exposing such counters? > Roland> We won't be adding any published interfaces using variables. > > I think that's OK. Do you think it would be OK to add a function > which returns the address of one of several "atomic counter" variables? That is a reasonable kind of interface in general. The trouble here is that glibc does not have any exported interfaces using atomic counters. The right type to use for these is machine-dependent; `int' is not the proper thing to be using in the interface. The types used in atomic.h are fine, but that is not an exported interface. We don't want to export it in that form. Unless you want to wait for that, this seems like a blocker for that style of interface. > enum { > AC_DL_LOAD_ADDITIONS, > AC_DL_LOAD_REMOVALS > } libc_atomic_counter_t; For an exported interface using a parameter like this does not seem like the best plan to me. If new flavors are added, this is not well-expressed for ABI compatibility. To me, the simplest way to do compatibility issues right is to use single-purpose entrypoints with separate names so symbol versioning will just take care of it. So, add a single entrypoint specifically for these two counters now. If you change it in the future, you can add entrypoints or change the old entrypoint signature under the same name using symbol versioning. > In any case, if a callback-based approach is preferred, I can live > with that, too. I don't claim it's the best interface. But that is the approach that doesn't have other blocking issues right now. From jakub@redhat.com Sat Jan 17 01:39:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 17 Jan 2004 01:39:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: <200401170057.i0H0vQag022225@magilla.sf.frob.com> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> Message-ID: <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> On Fri, Jan 16, 2004 at 04:57:26PM -0800, Roland McGrath wrote: > > In any case, if a callback-based approach is preferred, I can live > > with that, too. > > I don't claim it's the best interface. But that is the approach that > doesn't have other blocking issues right now. How about extending struct dl_phdr_info and passing an counter in it to dl_iterate_phdr's callback? The structure can be extended at the end, because dl_iterate_phdr passes its size to the callback as well. The callback is called with dl_load_lock held, so the counter doesn't even have to be atomic. libgcc_s would just see if size includes the additional field in the first callback, if yes, it would record that counter and on subsequent dl_iterate_phdr call it would first check whether the counter did not change and if it is the same, it could use cached info. Jakub From roland@redhat.com Sat Jan 17 01:40:00 2004 From: roland@redhat.com (Roland McGrath) Date: Sat, 17 Jan 2004 01:40:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: Jakub Jelinek's message of Saturday, 17 January 2004 00:29:31 +0100 <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> Message-ID: <200401170140.i0H1erss022346@magilla.sf.frob.com> > How about extending struct dl_phdr_info and passing an counter in it > to dl_iterate_phdr's callback? That is easy enough. OTOH, it's arguably not much harder for the callback to just compare the results with saved results from the last run and decide that way no new work has to be done. That works with existing glibc's too. From davidm@napali.hpl.hp.com Sat Jan 17 01:51:00 2004 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Sat, 17 Jan 2004 01:51:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> Message-ID: <16392.38158.910091.724717@napali.hpl.hp.com> >>>>> On Sat, 17 Jan 2004 00:29:31 +0100, Jakub Jelinek said: Jakub> On Fri, Jan 16, 2004 at 04:57:26PM -0800, Roland McGrath wrote: >> > In any case, if a callback-based approach is preferred, I can live >> > with that, too. >> I don't claim it's the best interface. But that is the approach that >> doesn't have other blocking issues right now. Jakub> How about extending struct dl_phdr_info and passing an counter in it Jakub> to dl_iterate_phdr's callback? Jakub> The structure can be extended at the end, because dl_iterate_phdr Jakub> passes its size to the callback as well. Jakub> The callback is called with dl_load_lock held, so the counter doesn't Jakub> even have to be atomic. Jakub> libgcc_s would just see if size includes the additional field in the Jakub> first callback, if yes, it would record that counter and on subsequent Jakub> dl_iterate_phdr call it would first check whether the counter did not Jakub> change and if it is the same, it could use cached info. Sounds good to me. I assume it'd be OK to have separate "additions" and "removals" counters? Only the latter is needed for avoiding stale values in a cache, but the former helps performance, because dl_iterate_phdr() can be stopped early if we know that the list didn't change. I'd be happy to prototype the necessary code, but at the moment, glibc doesn't build for me on ia64 (it crashes in rpcgen). I assume that's due to the stuff Uli is working on. --david From roland@redhat.com Mon Jan 19 03:31:00 2004 From: roland@redhat.com (Roland McGrath) Date: Mon, 19 Jan 2004 03:31:00 -0000 Subject: versioning In-Reply-To: Andreas Jaeger's message of Sunday, 7 December 2003 11:40:13 +0100 Message-ID: <200401190331.i0J3V6X5007641@magilla.sf.frob.com> > I agree with these stability issues. To have a stable version (ABI > wise) every two weeks restrains us. [...] > That could be done, I agree. We should put the date in the installed > glibc, e.g. as above. But what's the difference between a version > number and a date in this regard? The difference between a date and a version number is what convention we associate with them. Basically, the de facto convention is that version numbers are associated with firm APIs and ABIs. The reason I suggested snapshot dates as a nomenclature is to have something that is clearly not a deliberate stable point of API/ABI development. That makes quite distinct the meaning of the next assigned version number, which can correspond to symbol version set names denoting newly-firmed ABIs. My motivation is to have agreement that is clear amongst ourselves, and clear to users, when ABIs are firm and when they are not. I am open to whatever details get us there. > What might work is a release branch. I would make a branch point and > port all bugfixes from mainline to this branch and then release a > glibc version - let's say a few weeks (2-4) after the branch. The > next distributor would do the same at some point of time - and we > might even see several release branches at one time :-(. My suggestion about retroactively declaring releases from prior snapshots was simply motivated by the idea of formalizing existing communal practice. I didn't suggest branches because we have not (as a community project) been using them in a meaningful way before now. I think doing so might well be a mighty fine thing. I am only looking for whatever solutions will in fact be a useful formalization of how people do now work, or would prefer to be able to work, together on glibc. The reality is that each distribution maintainer does have a release branch. There is no shame in having several such release branches--if they are actively maintained branches representing the releases major distributions are actually using. These forks exist already in the world and in the daily work of the people who participate here in communal glibc development. Each distribution's glibc maintenance operates similarly to what you described for SuSE. Jakub does that for Fedora/Red Hat. Others on this list do the same for Debian. This has always been done separate from the community glibc source repository. If those maintainers would like to use branches in the shared public repository for this, I think that would be great. Jakub maintains Red Hat's branch of GCC this way, and that seems to be working out well. I think keeping the different branches in a shared repository is a great way to facilitate everyone's tracking of development and maintenance. I figure anything that streamlines the process of sharing code is a boon to overall efficiency of maintenance. But this can only be worthwhile if the distribution maintainers want to do it. I do not speak for any of them. If people don't want to do it, it's moot. An important component of Ulrich's original notion was the need to recognize the way glibc release, distribution, and maintenance is in fact taking place. We don't need bureaucracy to help the communal effort catch up. We need to start with the separate efforts that have been doing the job in the real world, leverage those, formalize what really does take place already, and collectively improve it from there. There will probably always be differences between the glibc release branches used by different distributions. Each has its own compatibility obligations, usage circumstances, and policy decisions that may well never be agreed as appropriate for the official community standard glibc code base. That is fine. What we are concerned with here is that which can be shared. An official release branch is only useful if the distribution maintainers find it of practical aid to their productivity and effectiveness. It's not to anyone's benefit if maintaining the release branch per se is an extra chore with no inherent utility. If there are multiple distribution release branches, then I would hope that it would be natural and easy to maintain a communal release branch that contains exactly the fixes that everyone is going to use in their own releases. If the forks keep in synch this way so that when code is taken into a branch, its text matches exactly with the shared release branch, the diffs between a distribution's glibc and the canonical release branch will be just the minimum that they have to be. Then the tip of the shared branch can be named an official release yielding canonical tarball contents, and each different flavor of glibc source package will need only that and a small distribution-specific amount of patching. I think it would be great to do this in the future. But there is no point in me specifying how it would be. The distribution maintainers have to say what they want to do. I am eager to hear. We have not really had "release freezes" (at least lately). But there are "quiet" periods where ABIs are not being perturbed and everyone is focussed on stabilizing changes. For example, since version.h was bumped to 2.3.3, there were no ABI additions and there were lots of necessary bug fixes in recent weeks. Only in the last few days have 2.3.4 symbols been added. Up until then, the trunk could have been said to have been in release freeze for 2.3.3 (if we had such a formal process, which we don't). If we did make release branches, we might not want to have made one before 2004-1-13 or so. That is, the way branches are done should follow what development is doing at any given time, not try to be rigid. OTOH, if we had a formal process of freezing ABI changes to version sets, we'd better have done that earlier, since OS distributions shipped with GLIBC_2.3.3 version sets before then. To me that emphasizes the need to better formalize what is going on now, without trying to slow it down. I've written a lot. But I think we really just need to do a few straightforward things to cooperate in a more efficient way that helps all of our work. If everyone is committed, I think making it happen will come easily, and I look forward to facilitating that. Thanks, Roland From roland@redhat.com Mon Jan 19 04:10:00 2004 From: roland@redhat.com (Roland McGrath) Date: Mon, 19 Jan 2004 04:10:00 -0000 Subject: bugzilla for glibc: no more glibcbug? Message-ID: <200401190410.i0J4ANGt007722@magilla.sf.frob.com> We are more or less ready to go with bugzilla for glibc bugs. That is, either more or less ready depending on what the criteria for "ready" are. What is not available is a way to submit new bugzilla reports via email. (There is, however, support for adding comments to bugs via email, and retrieving bug information via email.) This means that the `glibcbug' script as we have had it before cannot work. Instead, we would replace the various things saying to use glibcbug or bug-glibc with a URL for a web page. Do people have a problem with this? I'm told that for GCC bugzilla, almost no reports are submitted via email and people don't mind using the web interface. I imagine we can expect the same response from glibc users as from GCC users. It's possible we could support email parsing for submitting reports, both to have a new email-based glibc script, and to support uses of old glibc scripts sending to the existing email aliases. But to do that would require Daniel Berlin doing some hacking on the filter code for us out of the kindness of his heart, or someone volunteering to help him do it. So I don't consider lack of email submission and loss of `glibcbug' an impediment unless people here object. The reason I figure people won't object to abandoning the existing bug reporting mechanisms entirely is that they have been completely useless for many months, i.e. we have already abandoned them and not been complaining at each other about it very much. For the same reason I am guessing that people don't strongly feel that the old gnats PRs need to be migrated. This too might well be doable, though I have yet to ascertain if the gnats.gnu.org database can even be retrieved (nor heard in a long time from anyone who would know). But again, it has been a black hole for months. Nearly everything in it must surely be very out of date. Moreover, everyone has been getting along without it. Since all we have now is a black hole, relative to that I see an unequivocal improvement in going to a fresh clean slate. Comments? Thanks, Roland From drepper@redhat.com Mon Jan 19 07:59:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 19 Jan 2004 07:59:00 -0000 Subject: bugzilla for glibc: no more glibcbug? In-Reply-To: <200401190410.i0J4ANGt007722@magilla.sf.frob.com> References: <200401190410.i0J4ANGt007722@magilla.sf.frob.com> Message-ID: <400B8E64.6090701@redhat.com> Roland McGrath wrote: > Since all we have now is a black hole, relative to that I see an > unequivocal improvement in going to a fresh clean slate. Yes, that's fine. The first person who complains gets the honor of implementing and maintaining the script to file bugs without a browser. And the old bugs are, well, old. Before the final demise I looked through the database and haven't seen anything particularly interesting or urgent in there. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From jakub@redhat.com Mon Jan 19 14:21:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 19 Jan 2004 14:21:00 -0000 Subject: [PATCH] Fix accesses to uninitialized memory in get_subexp Message-ID: <20040119121345.GQ6413@sunsite.ms.mff.cuni.cz> Hi! get_subexp would happily compare bytes beyond end of buffer (or beyond end of valid chars). 2004-01-19 Jakub Jelinek * posix/regexec.c (get_subexp): Remove bkref_str variable. Extend buffers if needed before comparisons. (get_subexp_sub): Handle clean_state_log_if_needed failure. --- libc/posix/regexec.c.jj 2004-01-03 13:42:56.000000000 +0100 +++ libc/posix/regexec.c 2004-01-19 15:00:53.000000000 +0100 @@ -2551,7 +2551,6 @@ get_subexp (mctx, bkref_node, bkref_str_ re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx]; re_sub_match_last_t *sub_last; int sub_last_idx, sl_str, bkref_str_off; - const char *bkref_str; if (dfa->nodes[sub_top->node].opr.idx != subexp_num) continue; /* It isn't related. */ @@ -2567,9 +2566,24 @@ get_subexp (mctx, bkref_node, bkref_str_ sl_str_diff = sub_last->str_idx - sl_str; /* The matched string by the sub expression match with the substring at the back reference? */ - if (sl_str_diff > 0 - && memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0) - break; /* We don't need to search this sub expression any more. */ + if (sl_str_diff > 0) + { + if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0)) + { + /* Not enough chars for a successful match. */ + if (bkref_str_off + sl_str_diff > mctx->input.len) + break; + + err = clean_state_log_if_needed (mctx, + bkref_str_off + + sl_str_diff); + if (BE (err != REG_NOERROR, 0)) + return err; + buf = (const char *) re_string_get_buffer (&mctx->input); + } + if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0) + break; /* We don't need to search this sub expression any more. */ + } bkref_str_off += sl_str_diff; sl_str += sl_str_diff; err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, @@ -2584,7 +2598,6 @@ get_subexp (mctx, bkref_node, bkref_str_ if (BE (err != REG_NOERROR, 0)) return err; } - bkref_str = buf + bkref_str_off; if (sub_last_idx < sub_top->nlasts) continue; @@ -2598,8 +2611,24 @@ get_subexp (mctx, bkref_node, bkref_str_ sl_str_off = sl_str - sub_top->str_idx; /* The matched string by the sub expression match with the substring at the back reference? */ - if (sl_str_off > 0 && *bkref_str++ != buf[sl_str - 1]) - break; /* We don't need to search this sub expression any more. */ + if (sl_str_off > 0) + { + if (BE (bkref_str_off >= mctx->input.valid_len, 0)) + { + /* If we are at the end of the input, we cannot match. */ + if (bkref_str_off >= mctx->input.len) + break; + + err = extend_buffers (mctx); + if (BE (err != REG_NOERROR, 0)) + return err; + + buf = (const char *) re_string_get_buffer (&mctx->input); + } + if (buf [bkref_str_off++] != buf[sl_str - 1]) + break; /* We don't need to search this sub expression + any more. */ + } if (mctx->state_log[sl_str] == NULL) continue; /* Does this state have a ')' of the sub expression? */ @@ -2659,8 +2688,7 @@ get_subexp_sub (mctx, sub_top, sub_last, if (BE (err != REG_NOERROR, 0)) return err; to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx; - clean_state_log_if_needed (mctx, to_idx); - return REG_NOERROR; + return clean_state_log_if_needed (mctx, to_idx); } /* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX. Jakub From drepper@redhat.com Mon Jan 19 20:17:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 19 Jan 2004 20:17:00 -0000 Subject: [PATCH] Fix accesses to uninitialized memory in get_subexp In-Reply-To: <20040119121345.GQ6413@sunsite.ms.mff.cuni.cz> References: <20040119121345.GQ6413@sunsite.ms.mff.cuni.cz> Message-ID: <400C3B34.6000507@redhat.com> Jakub Jelinek wrote: > * posix/regexec.c (get_subexp): Remove bkref_str variable. > Extend buffers if needed before comparisons. > (get_subexp_sub): Handle clean_state_log_if_needed failure. Applied, thanks. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From sjmunroe@us.ibm.com Mon Jan 19 20:31:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Mon, 19 Jan 2004 20:31:00 -0000 Subject: PPC64 In my absence Message-ID: <400C3E55.5090408@us.ibm.com> I will be on vacation starting tomorrow and returning January 29th. I have asked Tom Gall to watch and provide updates/fixes for PowerPC64 and the VMX patches while I am gone. From roland@redhat.com Mon Jan 19 20:44:00 2004 From: roland@redhat.com (Roland McGrath) Date: Mon, 19 Jan 2004 20:44:00 -0000 Subject: bugzilla for glibc: no more glibcbug? In-Reply-To: Ulrich Drepper's message of Sunday, 18 January 2004 23:59:32 -0800 <400B8E64.6090701@redhat.com> Message-ID: <200401192044.i0JKi2MM010884@magilla.sf.frob.com> > Yes, that's fine. The first person who complains gets the honor of > implementing and maintaining the script to file bugs without a browser. > And the old bugs are, well, old. Before the final demise I looked > through the database and haven't seen anything particularly interesting > or urgent in there. Ok, great. Daniel indicated he might work on conversion scripts, but I am certainly happier being able to tell him there is no call for it. Thanks, Roland From sjmunroe@us.ibm.com Mon Jan 19 22:46:00 2004 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Mon, 19 Jan 2004 22:46:00 -0000 Subject: [RFC] Vector extentions for vprintf/vscanf Message-ID: <400C5DB8.7010400@us.ibm.com> A number of platforms support Vector (SIMD) extentions that support with types and builtins in gcc. This includes i386 MMX, 3Dnow!, SSE, SSE2, PowerPC 32 (and now PowerPC64) Altivec/VMX. One useful extention to glibc would be adding vector formating to printf/scanf. This would add the type modifier prefix v to the type modifiers hh, h, l. For example to print a vector of 16 signed bytes "%vhhd", 8 signed shorts "%vhd", 4 signed ints "%vd", or 4 floats "%vhf". (note the form "%vf" is reserved for a vector of 2 doubles but most current Vector SIMD implimentations don't support double float). We would be happy to provide the supporting patches and documentation if there is interrest. From rth@twiddle.net Tue Jan 20 00:19:00 2004 From: rth@twiddle.net (Richard Henderson) Date: Tue, 20 Jan 2004 00:19:00 -0000 Subject: [RFC] Vector extentions for vprintf/vscanf In-Reply-To: <400C5DB8.7010400@us.ibm.com> References: <400C5DB8.7010400@us.ibm.com> Message-ID: <20040120001950.GA3410@twiddle.net> On Mon, Jan 19, 2004 at 04:44:08PM -0600, Steve Munroe wrote: > One useful extention to glibc would be adding vector formating to > printf/scanf. This would add the type modifier prefix v to the type > modifiers hh, h, l. For example to print a vector of 16 signed bytes > "%vhhd", 8 signed shorts "%vhd", 4 signed ints "%vd", or 4 floats > "%vhf". (note the form "%vf" is reserved for a vector of 2 doubles but > most current Vector SIMD implimentations don't support double float). Are you going to hard-code the width of the vector? That's not friendly for x86, where there are two sizes. r~ From roland@redhat.com Tue Jan 20 02:46:00 2004 From: roland@redhat.com (Roland McGrath) Date: Tue, 20 Jan 2004 02:46:00 -0000 Subject: bugzilla for glibc: let's get moving! Message-ID: <200401200246.i0K2kMXm011897@magilla.sf.frob.com> If you are listed in the CC: header, please reply to this message (see below)! I think we are ready to start using bugzilla for glibc. So let's get this show on the road! There are plenty of things still to figure out about how we use the system. But there's no better way to hash those out than to get started with trying to use it. If you are reading this message and you do not already have an account on http://sources.redhat.com/bugzilla/ then please go sign up right now! Choose for your bugzilla account the email address that you would like email about glibc bugs sent to. Take a look at http://www.gnu.org/software/libc/bugs.html and tell me if you have any comments or suggestions for that page. My intent is to make that URL the single canonical reference for glibc bug reporting; it says a few things and has links to bugzilla. All the various places that embed an email address or instructions to use glibcbug will instead give this one URL. If the details of the bug system change again in the future, that page's links can be updated to point to a new system. Once I finish getting web pages and email aliases set up, I will commit some changes en masse to make everything in the source tree refer to the new (and hopefully permanent this time) places. There wasn't much response to my previous posting about components we'll use in bugzilla to categorize bug reports. I am again proposing a list of components, with initial owners. The person listed as owner will be the person who gets automatically assigned bug reports filed under this category. That doesn't mean you have to fix it, it just means you are committing to seeing it first and passing the buck to somebody. gotom has volunteered to do triage, and so any report that lacks adequate information in the common ways can just be reassigned to him for the usual feedback and verification. If you really don't want to see any report before it's been vetted, gotom can be the owner of your component in the system. But there is plenty of work already entailed in what he has volunteered to take on for us. If you are listed below, please reply to ACK your assignment. Or NAK if you find anything wrong with the list of components here, or don't want to be on record as a component's owner. I would like to get this agreed to ASAP so we can start using the system. Components can be added or removed later, so it's fine if all this is tentative. It might get hairy to remove or rename one once bug reports exist. But it should never be a problem to add more later and reclassify bugs under the new distinctions, so we don't need to think too hard about this ahead of time. admin: roland (Web pages, bugzilla, etc.) libc: gotom (Catch-all and default place for triage.) faq: aj hurd: roland linuxthreads: jakub localedata: pere manual: roland nis: kukuk nptl: drepper regex: jakub (These I presume are self-explanatory.) Thanks, Roland From drepper@redhat.com Tue Jan 20 03:38:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 20 Jan 2004 03:38:00 -0000 Subject: [RFC] Vector extentions for vprintf/vscanf In-Reply-To: <400C5DB8.7010400@us.ibm.com> References: <400C5DB8.7010400@us.ibm.com> Message-ID: <400CA2C0.4070301@redhat.com> Steve Munroe wrote: > One useful extention to glibc would be adding vector formating to > printf/scanf. Never. Write your printf handlers, put them in a separate library, and register them using the interface in . -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From aj@suse.de Tue Jan 20 06:41:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Tue, 20 Jan 2004 06:41:00 -0000 Subject: bugzilla for glibc: let's get moving! In-Reply-To: <200401200246.i0K2kMXm011897@magilla.sf.frob.com> (Roland McGrath's message of "Mon, 19 Jan 2004 18:46:22 -0800") References: <200401200246.i0K2kMXm011897@magilla.sf.frob.com> Message-ID: Roland McGrath writes: > If you are listed in the CC: header, please reply to this message (see below)! > > I think we are ready to start using bugzilla for glibc. So let's get this > show on the road! There are plenty of things still to figure out about how > we use the system. But there's no better way to hash those out than to get > started with trying to use it. > > If you are reading this message and you do not already have an account on > http://sources.redhat.com/bugzilla/ then please go sign up right now! > Choose for your bugzilla account the email address that you would like > email about glibc bugs sent to. > > Take a look at http://www.gnu.org/software/libc/bugs.html and tell me if > you have any comments or suggestions for that page. My intent is to make > that URL the single canonical reference for glibc bug reporting; it says a > few things and has links to bugzilla. All the various places that embed an > email address or instructions to use glibcbug will instead give this one > URL. If the details of the bug system change again in the future, that > page's links can be updated to point to a new system. Once I finish > getting web pages and email aliases set up, I will commit some changes en > masse to make everything in the source tree refer to the new (and hopefully > permanent this time) places. Good idea. I suggest to look at the GCC bug page and copy stuff from there. We should explictly stress that we need self-contained testcases and cannot debug any complex programs. > There wasn't much response to my previous posting about components we'll > use in bugzilla to categorize bug reports. I am again proposing a list of > components, with initial owners. The person listed as owner will be the > person who gets automatically assigned bug reports filed under this > category. That doesn't mean you have to fix it, it just means you are > committing to seeing it first and passing the buck to somebody. gotom has > volunteered to do triage, and so any report that lacks adequate information > in the common ways can just be reassigned to him for the usual feedback and > verification. If you really don't want to see any report before it's been > vetted, gotom can be the owner of your component in the system. But there > is plenty of work already entailed in what he has volunteered to take on > for us. This is fine. > If you are listed below, please reply to ACK your assignment. Or NAK if > you find anything wrong with the list of components here, or don't want to > be on record as a component's owner. I would like to get this agreed to > ASAP so we can start using the system. Components can be added or removed > later, so it's fine if all this is tentative. It might get hairy to remove > or rename one once bug reports exist. But it should never be a problem to > add more later and reclassify bugs under the new distinctions, so we don't > need to think too hard about this ahead of time. Btw. are we setting up a mailing list like gcc-bugs that gets all bugs? > > admin: roland > (Web pages, bugzilla, etc.) > > libc: gotom > (Catch-all and default place for triage.) > faq: aj Ok. > hurd: roland > linuxthreads: jakub > localedata: pere > manual: roland > nis: kukuk > nptl: drepper > regex: jakub > (These I presume are self-explanatory.) We should add architecture specific bugs and the usual port maintainers as default. Also I suggest to add: math (libm): aj nscd: kukuk Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From roland@redhat.com Tue Jan 20 07:09:00 2004 From: roland@redhat.com (Roland McGrath) Date: Tue, 20 Jan 2004 07:09:00 -0000 Subject: bugzilla for glibc: let's get moving! In-Reply-To: Andreas Jaeger's message of Tuesday, 20 January 2004 07:41:27 +0100 Message-ID: <200401200709.i0K79S34012285@magilla.sf.frob.com> > I suggest to look at the GCC bug page and copy stuff from there. We > should explictly stress that we need self-contained testcases and > cannot debug any complex programs. http://gcc.gnu.org/bugs.html says lots of useful details about how to write a good bug report. If someone wants to write up text like that for libc, that would be great. If something really useful is written up, it should probably go in the Reporting Bugs node in the manual (install.texi) as well. I don't really have time to do that writing. > Btw. are we setting up a mailing list like gcc-bugs that gets all bugs? I will inquire about this. > We should add architecture specific bugs and the usual port > maintainers as default. This is a possibility. There is also the "host triplet" field in bug reports. This is something you can do selective queries on easily enough. When triage verifies that a bug is machine-dependent, the bug could just be assigned to the canonical person for that port. I am not really against adding per-machine components, but I'm not sure it's what makes most sense. > Also I suggest to add: > math (libm): aj > nscd: kukuk Good ideas. Thanks, Roland From aj@suse.de Tue Jan 20 07:16:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Tue, 20 Jan 2004 07:16:00 -0000 Subject: bugzilla for glibc: let's get moving! In-Reply-To: <200401200709.i0K79S34012285@magilla.sf.frob.com> (Roland McGrath's message of "Mon, 19 Jan 2004 23:09:28 -0800") References: <200401200709.i0K79S34012285@magilla.sf.frob.com> Message-ID: Roland McGrath writes: >> I suggest to look at the GCC bug page and copy stuff from there. We >> should explictly stress that we need self-contained testcases and >> cannot debug any complex programs. > > http://gcc.gnu.org/bugs.html says lots of useful details about how to write > a good bug report. If someone wants to write up text like that for libc, > that would be great. If something really useful is written up, it should > probably go in the Reporting Bugs node in the manual (install.texi) as well. > I don't really have time to do that writing. So, let's ask for some volunteers ;-) >> Btw. are we setting up a mailing list like gcc-bugs that gets all bugs? > > I will inquire about this. Thanks. >> We should add architecture specific bugs and the usual port >> maintainers as default. > > This is a possibility. There is also the "host triplet" field in bug > reports. This is something you can do selective queries on easily enough. > When triage verifies that a bug is machine-dependent, the bug could just be > assigned to the canonical person for that port. I am not really against > adding per-machine components, but I'm not sure it's what makes most sense. Then let's go first without it and later see whether we need it... >> Also I suggest to add: >> math (libm): aj >> nscd: kukuk > > Good ideas. Fine, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From davidm@napali.hpl.hp.com Thu Jan 22 00:35:00 2004 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Thu, 22 Jan 2004 00:35:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> Message-ID: <16399.6885.708290.614809@napali.hpl.hp.com> >>>>> On Sat, 17 Jan 2004 00:29:31 +0100, Jakub Jelinek said: Jakub> How about extending struct dl_phdr_info and passing an Jakub> counter in it to dl_iterate_phdr's callback? How about the attached patch? It seems to work for me at least for this simple test program: $ cat ~/tmp/t.c #include #include static int callback (struct dl_phdr_info *info, size_t size, void *ptr) { printf (" size = %Zu ", size); printf ("dlpi_adds = %u ", info->dlpi_adds); printf ("dlpi_subs = %u\n", info->dlpi_subs); return -1; } int main (int argc, char **argv) { void *handle; int ret; dl_iterate_phdr (callback, NULL); handle = dlopen ("libunwind.so", RTLD_LAZY); printf ("dlopen(libunwind.so)=%p\n", handle); dl_iterate_phdr (callback, NULL); ret = dlclose (handle); printf ("dlclose(libunwind.so)=%d\n", ret); dl_iterate_phdr (callback, NULL); return 0; } $ gcc -D_GNU_SOURCE -O -Wall t.c -I/tmp/davidm/usr/include/ -ldl $ ./a.out size = 40 dlpi_adds = 4 dlpi_subs = 0 dlopen(libunwind.so)=0x20000008002e0030 size = 40 dlpi_adds = 5 dlpi_subs = 0 dlclose(libunwind.so)=0 size = 40 dlpi_adds = 5 dlpi_subs = 1 In terms of performance, this is clearly more expensive than just checking a variable. For libunwind, the approach adds about 5% to the time required to initialize a stack unwind, but just hitting once in the cache during the actual unwind will easily make up for the extra cost, so I think it's OK. Comments? --david Index: elf/dl-close.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-close.c,v retrieving revision 1.98 diff -u -r1.98 dl-close.c --- elf/dl-close.c 27 Apr 2003 06:19:09 -0000 1.98 +++ elf/dl-close.c 22 Jan 2004 00:26:54 -0000 @@ -319,6 +319,7 @@ /* Notify the debugger we are about to remove some loaded objects. */ _r_debug.r_state = RT_DELETE; _dl_debug_state (); + ++GL(dl_load_subs); #ifdef USE_TLS size_t tls_free_start; Index: elf/dl-iteratephdr.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-iteratephdr.c,v retrieving revision 1.9 diff -u -r1.9 dl-iteratephdr.c --- elf/dl-iteratephdr.c 22 Oct 2003 07:09:41 -0000 1.9 +++ elf/dl-iteratephdr.c 22 Jan 2004 00:26:54 -0000 @@ -48,6 +48,8 @@ info.dlpi_name = l->l_name; info.dlpi_phdr = l->l_phdr; info.dlpi_phnum = l->l_phnum; + info.dlpi_adds = GL(dl_load_adds); + info.dlpi_subs = GL(dl_load_subs); ret = callback (&info, sizeof (struct dl_phdr_info), data); if (ret) break; @@ -84,6 +86,8 @@ info.dlpi_name = ""; info.dlpi_phdr = _dl_phdr; info.dlpi_phnum = _dl_phnum; + info.dlpi_adds = GL(dl_load_adds); + info.dlpi_subs = GL(dl_load_subs); ret = (*callback) (&info, sizeof (struct dl_phdr_info), data); if (ret) return ret; Index: elf/dl-object.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-object.c,v retrieving revision 1.36 diff -u -r1.36 dl-object.c --- elf/dl-object.c 25 Apr 2003 09:06:56 -0000 1.36 +++ elf/dl-object.c 22 Jan 2004 00:26:54 -0000 @@ -83,6 +83,7 @@ else GL(dl_loaded) = new; ++GL(dl_nloaded); + ++GL(dl_load_adds); /* If we have no loader the new object acts as it. */ if (loader == NULL) Index: elf/dl-support.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-support.c,v retrieving revision 1.79 diff -u -r1.79 dl-support.c --- elf/dl-support.c 13 Jan 2004 15:41:27 -0000 1.79 +++ elf/dl-support.c 22 Jan 2004 00:26:54 -0000 @@ -71,6 +71,11 @@ /* Number of object in the _dl_loaded list. */ unsigned int _dl_nloaded; +/* Incremented whenever something may have been added to dl_loaded. */ +unsigned int _dl_load_adds; +/* Incremented whenever something may have been removed from dl_loaded. */ +unsigned int _dl_load_subs; + /* Fake scope. In dynamically linked binaries this is the scope of the main application but here we don't have something like this. So create a fake scope containing nothing. */ Index: elf/link.h =================================================================== RCS file: /cvs/glibc/libc/elf/link.h,v retrieving revision 1.76 diff -u -r1.76 link.h --- elf/link.h 16 Sep 2003 05:48:04 -0000 1.76 +++ elf/link.h 22 Jan 2004 00:26:54 -0000 @@ -100,6 +100,12 @@ const char *dlpi_name; const ElfW(Phdr) *dlpi_phdr; ElfW(Half) dlpi_phnum; + + /* Note: older versions of libc do not provide the following + members. Check the SIZE argument pass to the dl_iterate_phdr() + callback to determine whether or not they areprovided. */ + unsigned int dlpi_adds; /* incremented when phdrs may have been added */ + unsigned int dlpi_subs; /* incremented when phdrs may have been removed */ }; __BEGIN_DECLS Index: include/link.h =================================================================== RCS file: /cvs/glibc/libc/include/link.h,v retrieving revision 1.29 diff -u -r1.29 link.h --- include/link.h 13 Jan 2004 08:27:52 -0000 1.29 +++ include/link.h 22 Jan 2004 00:26:55 -0000 @@ -293,6 +293,12 @@ const char *dlpi_name; const ElfW(Phdr) *dlpi_phdr; ElfW(Half) dlpi_phnum; + + /* Note: older versions of libc do not provide the following + members. Check the SIZE argument pass to the dl_iterate_phdr() + callback to determine whether or not they areprovided. */ + unsigned int dlpi_adds; /* incremented when phdrs may have been added */ + unsigned int dlpi_subs; /* incremented when phdrs may have been removed */ }; extern int dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, Index: sysdeps/generic/ldsodefs.h =================================================================== RCS file: /cvs/glibc/libc/sysdeps/generic/ldsodefs.h,v retrieving revision 1.87 diff -u -r1.87 ldsodefs.h --- sysdeps/generic/ldsodefs.h 15 Jan 2004 06:37:40 -0000 1.87 +++ sysdeps/generic/ldsodefs.h 22 Jan 2004 00:26:55 -0000 @@ -265,6 +265,11 @@ EXTERN const char *_dl_platform; EXTERN size_t _dl_platformlen; + /* Incremented whenever something may have been added to dl_loaded. */ + EXTERN unsigned int _dl_load_adds; + /* Incremented whenever something may have been removed from dl_loaded. */ + EXTERN unsigned int _dl_load_subs; + #ifndef MAP_ANON /* File descriptor referring to the zero-fill device. */ EXTERN int _dl_zerofd; From aj@suse.de Thu Jan 22 07:24:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Thu, 22 Jan 2004 07:24:00 -0000 Subject: [rfc] dwarf2 backtrace from setcontext In-Reply-To: <20040112155217.A30317@redhat.com> (Richard Henderson's message of "Mon, 12 Jan 2004 15:52:17 -0800") References: <20040111025223.A2564@redhat.com> <20040111030005.C13258@redhat.com> <20040111202020.GB24540@redhat.com> <20040111213631.GD24540@redhat.com> <20040112231919.GB27775@nevyn.them.org> <20040112155217.A30317@redhat.com> Message-ID: Richard Henderson writes: > On Mon, Jan 12, 2004 at 06:19:19PM -0500, Daniel Jacobowitz wrote: >> It seems to me that the best solution would be a new rule, either >> val_expression(E) or the simpler val_cfa_offset(N). Then the unwind >> information can accurately describe the stack pointer. > > That would certainly work for me. > >> That would probably work for this example - I can't see any reason that >> GDB would care. And for setcontext it makes a certain sense, since you >> do seem to have "fallen through" into a different backtrace. > > I'll recommend we do that for glibc then. Like the following? Andreas ============================================================ Index: sysdeps/unix/sysv/linux/x86_64/setcontext.S --- x86_64/setcontext.S 31 Aug 2002 08:05:51 -0000 1.2 +++ x86_64/setcontext.S 22 Jan 2004 07:24:29 -0000 @@ -1,5 +1,5 @@ /* Install given context. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 2002. @@ -35,6 +35,7 @@ ENTRY(__setcontext) /* Save argument since syscall will destroy it. */ pushq %rdi + cfi_adjust_cfa_offset(8) /* Set the signal mask with rt_sigprocmask (SIG_SETMASK, mask, NULL, _NSIG/8). */ @@ -45,6 +46,7 @@ ENTRY(__setcontext) movq $__NR_rt_sigprocmask, %rax syscall popq %rdi /* Reload %rdi, adjust stack. */ + cfi_adjust_cfa_offset(-8) cmpq $-4095, %rax /* Check %rax for error. */ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */ @@ -57,6 +59,9 @@ ENTRY(__setcontext) /* Load the new stack pointer, the preserved registers and registers used for passing args. */ + /* End FDE here, we fall into another context. */ + cfi_endproc + movq oRSP(%rdi), %rsp movq oRBX(%rdi), %rbx movq oRBP(%rdi), %rbp @@ -78,6 +83,9 @@ ENTRY(__setcontext) /* Setup finally %rdi. */ movq oRDI(%rdi), %rdi + + /* We changed %rdi, fix cfi. */ + cfi_startproc /* Clear rax to indicate success. */ xorq %rax, %rax -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Thu Jan 22 08:16:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Thu, 22 Jan 2004 08:16:00 -0000 Subject: [rfc] dwarf2 backtrace from setcontext In-Reply-To: <20040122080350.GA18412@redhat.com> (Richard Henderson's message of "Thu, 22 Jan 2004 00:03:50 -0800") References: <20040111030005.C13258@redhat.com> <20040111202020.GB24540@redhat.com> <20040111213631.GD24540@redhat.com> <20040112231919.GB27775@nevyn.them.org> <20040112155217.A30317@redhat.com> <20040122080350.GA18412@redhat.com> Message-ID: Thanks. Here's the version that I'm going to commit now, Andreas ============================================================ Index: sysdeps/unix/sysv/linux/x86_64/setcontext.S --- sysdeps/unix/sysv/linux/x86_64/setcontext.S 31 Aug 2002 08:05:51 -0000 1.2 +++ sysdeps/unix/sysv/linux/x86_64/setcontext.S 22 Jan 2004 08:16:49 -0000 @@ -1,5 +1,5 @@ /* Install given context. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 2002. @@ -35,6 +35,7 @@ ENTRY(__setcontext) /* Save argument since syscall will destroy it. */ pushq %rdi + cfi_adjust_cfa_offset(8) /* Set the signal mask with rt_sigprocmask (SIG_SETMASK, mask, NULL, _NSIG/8). */ @@ -45,6 +46,7 @@ ENTRY(__setcontext) movq $__NR_rt_sigprocmask, %rax syscall popq %rdi /* Reload %rdi, adjust stack. */ + cfi_adjust_cfa_offset(-8) cmpq $-4095, %rax /* Check %rax for error. */ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */ @@ -57,6 +59,16 @@ ENTRY(__setcontext) /* Load the new stack pointer, the preserved registers and registers used for passing args. */ + cfi_def_cfa(%rdi, 0) + cfi_offset(%rbx,oRBX) + cfi_offset(%rbp,oRBP) + cfi_offset(%r12,oR12) + cfi_offset(%r13,oR13) + cfi_offset(%r14,oR14) + cfi_offset(%r15,oR15) + cfi_offset(%rsp,oRSP) + cfi_offset(%rip,oRIP) + movq oRSP(%rdi), %rsp movq oRBX(%rdi), %rbx movq oRBP(%rdi), %rbp @@ -78,6 +90,10 @@ ENTRY(__setcontext) /* Setup finally %rdi. */ movq oRDI(%rdi), %rdi + + /* End FDE here, we fall into another context. */ + cfi_endproc + cfi_startproc /* Clear rax to indicate success. */ xorq %rax, %rax -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Thu Jan 22 08:39:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 22 Jan 2004 08:39:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: <16399.6885.708290.614809@napali.hpl.hp.com> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> <16399.6885.708290.614809@napali.hpl.hp.com> Message-ID: <20040122062944.GC6811@sunsite.ms.mff.cuni.cz> On Wed, Jan 21, 2004 at 04:35:49PM -0800, David Mosberger wrote: > --- elf/link.h 16 Sep 2003 05:48:04 -0000 1.76 > +++ elf/link.h 22 Jan 2004 00:26:54 -0000 > @@ -100,6 +100,12 @@ > const char *dlpi_name; > const ElfW(Phdr) *dlpi_phdr; > ElfW(Half) dlpi_phnum; > + > + /* Note: older versions of libc do not provide the following > + members. Check the SIZE argument pass to the dl_iterate_phdr() > + callback to determine whether or not they areprovided. */ > + unsigned int dlpi_adds; /* incremented when phdrs may have been added */ > + unsigned int dlpi_subs; /* incremented when phdrs may have been removed */ I'd make the counters unsigned long long instead to avoid wrap around. Also, could you write a testcase for it? dl_iterate_phdr, then dlopen some shlib in elf, then dl_iterate_phdr again, check the counters, dlclose etc. Jakub From aj@suse.de Thu Jan 22 10:40:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Thu, 22 Jan 2004 10:40:00 -0000 Subject: Warning removal Message-ID: This patch gets rid of GCC 3.4's warning: ../sysdeps/ieee754/dbl-64/e_pow.c:49: warning: conflicting types for built-in function 'log2' Ok to commit? Andreas 2004-01-22 Andreas Jaeger * sysdeps/ieee754/dbl-64/e_pow.c (log2): Rename to log2x to avoid warnings for builtin function log2. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: libc-diff URL: -------------- next part -------------- -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Thu Jan 22 11:03:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Thu, 22 Jan 2004 11:03:00 -0000 Subject: Get rid of warning in linuxthreads/spinlock.c Message-ID: this patch gets rid of: spinlock.c:33: warning: matching constraint does not allow a register Ok to commit? Andreas 2004-01-22 Andreas Jaeger * spinlock.c (__pthread_lock): Fix contraint to avoid warning. (__pthread_release): Likewise. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: libc-diff URL: -------------- next part -------------- -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Thu Jan 22 11:13:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Thu, 22 Jan 2004 11:13:00 -0000 Subject: Get rid of lvalue casts etc. Message-ID: GCC 3.4 has removed the support for casts as lvalues. :-( I'm appending a tested patch for glibc that fixes some of the problems. Ok to commit? Andreas 2004-01-22 Andreas Jaeger * iconv/gconv_simple.c (ucs4le_internal_loop): Remove cast used as lvalue. (internal_ucs4le_loop_single): Likewise. (ucs4_internal_loop): Likewise. (BODY): Likewise. * iconv/gconv_open.c (__gconv_open): Remove conditional expression as lvalue. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: libc-diff URL: -------------- next part -------------- -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From schwab@suse.de Thu Jan 22 13:24:00 2004 From: schwab@suse.de (Andreas Schwab) Date: Thu, 22 Jan 2004 13:24:00 -0000 Subject: Get rid of lvalue casts etc. In-Reply-To: (Andreas Jaeger's message of "Thu, 22 Jan 2004 12:13:53 +0100") References: Message-ID: Andreas Jaeger writes: > @@ -195,7 +197,8 @@ internal_ucs4_loop_single (struct __gcon > *outptrp += 4; > #elif __BYTE_ORDER == __BIG_ENDIAN > /* XXX unaligned */ > - *(*((uint32_t **) outptrp)++) = state->__value.__wch; > + *(*((uint32_t **) outptrp)) = state->__value.__wch; > + *outptrp += sizeof (uint32_t *); The big endian version was actually wrong, and sizeof(uint32_t*) makes it even worse. IMHO this should just be written like this: (*outptrp)[0] = state->__value.__wchb[0]; (*outptrp)[1] = state->__value.__wchb[1]; (*outptrp)[2] = state->__value.__wchb[2]; (*outptrp)[3] = state->__value.__wchb[3]; > @@ -558,7 +562,9 @@ internal_ucs4le_loop_single (struct __gc > *outptrp += 4; > #else > /* XXX unaligned */ > - *(*((uint32_t **) outptrp)++) = state->__value.__wch; > + > + *(*((uint32_t **) outptrp)) = state->__value.__wch; > + *outptrp += sizeof (uint32_t); Same here. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Maxfeldstra??e 5, 90409 N??rnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From jakub@redhat.com Thu Jan 22 16:43:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 22 Jan 2004 16:43:00 -0000 Subject: [PATCH] Fix PT_GNU_RELRO support Message-ID: <20040122143553.GE6811@sunsite.ms.mff.cuni.cz> Hi! This patch fixes 3 things. If ld.so is without PT_GNU_STACK but with PT_GNU_RELRO program header (say on ppc64), elf/ld.so --library-path . /bin/echo would segfault immediately because of writing into NULL GL(_dl_loaded). On !DONT_USE_BOOTSTRAP_MAP arches RELRO region info for the dynamic linker on the other side would not be recorded and thus not mprotected later. Last, for prelinked programs we need to mprotect as well (after _dl_resolve_conflicts finishes). 2004-01-22 Jakub Jelinek * elf/dl-reloc.c (_dl_relocate_object): Move PT_GNU_RELRO protection into... (_dl_protect_relro): New routine. * sysdeps/generic/ldsodefs.h (_dl_protect_relro): New prototype. * elf/rtld.c (_dl_start_final): Copy l_relro_addr and l_relro_size from bootstrap_map. (_dl_main): Don't set GL(_dl_loaded)->l_relro_{addr,size} here. Call _dl_protect_relro for libraries if prelinking. --- libc/elf/dl-reloc.c.jj 2004-01-22 12:03:00.000000000 +0100 +++ libc/elf/dl-reloc.c 2004-01-22 13:43:23.000000000 +0100 @@ -311,23 +311,25 @@ _dl_relocate_object (struct link_map *l, /* In case we can protect the data now that the relocations are done, do it. */ if (l->l_relro_size != 0) + _dl_protect_relro (l); +} +INTDEF (_dl_relocate_object) + +void internal_function +_dl_protect_relro (struct link_map *l) +{ + ElfW(Addr) start = ((l->l_addr + l->l_relro_addr) & ~(GL(dl_pagesize) - 1)); + ElfW(Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size) + & ~(GL(dl_pagesize) - 1)); + + if (start != end + && __mprotect ((void *) start, end - start, PROT_READ) < 0) { - ElfW(Addr) start = ((l->l_addr + l->l_relro_addr) - & ~(GL(dl_pagesize) - 1)); - ElfW(Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size) - & ~(GL(dl_pagesize) - 1)); - - if (start != end - && __mprotect ((void *) start, end - start, PROT_READ) < 0) - { - errstring = N_("\ + const char *errstring = N_("\ cannot apply additional memory protection after relocation"); - goto call_error; - } + INTUSE(_dl_signal_error) (errno, l->l_name, NULL, errstring); } } -INTDEF (_dl_relocate_object) - void internal_function __attribute_noinline__ --- libc/elf/rtld.c.jj 2004-01-22 12:02:12.000000000 +0100 +++ libc/elf/rtld.c 2004-01-22 14:08:55.000000000 +0100 @@ -224,6 +224,8 @@ _dl_start_final (void *arg, struct dl_st memcpy (GL(dl_rtld_map).l_info, info->l.l_info, sizeof GL(dl_rtld_map).l_info); GL(dl_rtld_map).l_mach = info->l.l_mach; + GL(dl_rtld_map).l_relro_addr = info->l.l_relro_addr; + GL(dl_rtld_map).l_relro_size = info->l.l_relro_size; #endif _dl_setup_hash (&GL(dl_rtld_map)); GL(dl_rtld_map).l_opencount = 1; @@ -794,11 +796,6 @@ of this helper program; chances are you GL(dl_stack_flags) = ph->p_flags; break; } - else if (ph->p_type == PT_GNU_RELRO) - { - GL(dl_loaded)->l_relro_addr = ph->p_vaddr; - GL(dl_loaded)->l_relro_size = ph->p_memsz; - } if (__builtin_expect (mode, normal) == verify) { @@ -1676,7 +1673,11 @@ cannot allocate TLS data structures for /* Mark all the objects so we know they have been already relocated. */ for (l = GL(dl_loaded); l != NULL; l = l->l_next) - l->l_relocated = 1; + { + l->l_relocated = 1; + if (l->l_relro_size) + _dl_protect_relro (l); + } _dl_sysdep_start_cleanup (); } --- libc/sysdeps/generic/ldsodefs.h.jj 2004-01-22 13:43:41.000000000 +0100 +++ libc/sysdeps/generic/ldsodefs.h 2004-01-22 13:47:57.000000000 +0100 @@ -697,6 +697,10 @@ extern void _dl_relocate_object_internal int lazy, int consider_profiling) attribute_hidden; +/* Protect PT_GNU_RELRO area. */ +extern void _dl_protect_relro (struct link_map *map) + internal_function attribute_hidden; + /* Call _dl_signal_error with a message about an unhandled reloc type. TYPE is the result of ELFW(R_TYPE) (r_info), i.e. an R__* value. PLT is nonzero if this was a PLT reloc; it just affects the message. */ Jakub From roland@redhat.com Thu Jan 22 22:09:00 2004 From: roland@redhat.com (Roland McGrath) Date: Thu, 22 Jan 2004 22:09:00 -0000 Subject: Warning removal In-Reply-To: Andreas Jaeger's message of Thursday, 22 January 2004 11:36:40 +0100 Message-ID: <200401222209.i0MM9NxU029310@magilla.sf.frob.com> > > This patch gets rid of GCC 3.4's warning: > ../sysdeps/ieee754/dbl-64/e_pow.c:49: warning: conflicting types for built-in function 'log2' > > Ok to commit? That looks fine to me, though a less obscure name line "my_log2" might be a littler better. From roland@redhat.com Thu Jan 22 23:12:00 2004 From: roland@redhat.com (Roland McGrath) Date: Thu, 22 Jan 2004 23:12:00 -0000 Subject: Get rid of warning in linuxthreads/spinlock.c In-Reply-To: Andreas Jaeger's message of Thursday, 22 January 2004 12:01:10 +0100 Message-ID: <200401222312.i0MNCnqp029474@magilla.sf.frob.com> > > this patch gets rid of: > > spinlock.c:33: warning: matching constraint does not allow a register > > Ok to commit? If using the "m" constraint works right in all gcc >= 3.2, then fine. > * spinlock.c (__pthread_lock): Fix contraint to avoid warning. ^typo From aj@suse.de Fri Jan 23 13:17:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Fri, 23 Jan 2004 13:17:00 -0000 Subject: Get rid of warning in linuxthreads/spinlock.c In-Reply-To: <200401222312.i0MNCnqp029474@magilla.sf.frob.com> (Roland McGrath's message of "Thu, 22 Jan 2004 15:12:49 -0800") References: <200401222312.i0MNCnqp029474@magilla.sf.frob.com> Message-ID: Roland McGrath writes: >> >> this patch gets rid of: >> >> spinlock.c:33: warning: matching constraint does not allow a register >> >> Ok to commit? > > If using the "m" constraint works right in all gcc >= 3.2, then fine. > Yes, it should. I tested with 3.3 and AFAIK only the warning is new... Ok, will commit now, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Fri Jan 23 13:35:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Fri, 23 Jan 2004 13:35:00 -0000 Subject: Warning removal In-Reply-To: <200401222209.i0MM9NxU029310@magilla.sf.frob.com> (Roland McGrath's message of "Thu, 22 Jan 2004 14:09:23 -0800") References: <200401222209.i0MM9NxU029310@magilla.sf.frob.com> Message-ID: Roland McGrath writes: >> >> This patch gets rid of GCC 3.4's warning: >> ../sysdeps/ieee754/dbl-64/e_pow.c:49: warning: conflicting types for built-in function 'log2' >> >> Ok to commit? > > That looks fine to me, though a less obscure name line "my_log2" might > be a littler better. Ok, changed it as suggested and will commit now, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From davidm@napali.hpl.hp.com Sat Jan 24 05:54:00 2004 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Sat, 24 Jan 2004 05:54:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: <20040122062944.GC6811@sunsite.ms.mff.cuni.cz> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> <16399.6885.708290.614809@napali.hpl.hp.com> <20040122062944.GC6811@sunsite.ms.mff.cuni.cz> Message-ID: <16402.2189.718828.875017@napali.hpl.hp.com> >>>>> On Thu, 22 Jan 2004 07:29:45 +0100, Jakub Jelinek said: Jakub> I'd make the counters unsigned long long instead to avoid Jakub> wrap around. Fine by me. Jakub> Also, could you write a testcase for it? dl_iterate_phdr, Jakub> then dlopen some shlib in elf, then dl_iterate_phdr again, Jakub> check the counters, dlclose etc. Sure. Attached is an updated patch. "make check subdirs=elf" passes all tests (including the new tst-dlmodcount test). If it looks OK, please apply. --david ChangeLog 2004-01-23 David Mosberger * sysdeps/generic/ldsodefs.h (struct rtld_global): Add members _dl_load_adds and _dl_load_subs. * elf/dl-support.c (_dl_load_adds): New variable. (_dl_load_subs): Likewise. * elf/dl-object.c (_dl_new_object): Increment dl_load_adds. * elf/dl-close.c (_dl_close): Increment dl_load_subs. * elf/link.h (struct dl_phdr_info): Add members dlpi_adds and dlpi_subs. * include/link.h: Likewise. * elf/dl-iteratephdr.c (__dl_iterate_phdr): Initialize dlpi_adds and dlpi_subs members. (dl_iterate_phdr): Likewise. * elf/tst-dlmodcount.c: New file. * elf/Makefile (distribute): Mention tst-dlmodcount.c. (tests): If build-shared, mention tst-dlmodcount. ($(objpfx)tst-dlmodcount): If build-shared, build and run tst-dlmodcount. Index: elf/Makefile --- elf/Makefile +++ elf/Makefile @@ -80,7 +80,7 @@ reldep9.c reldep9mod1.c reldep9mod2.c reldep9mod3.c \ tst-array1.exp tst-array2.exp tst-array4.exp \ tst-array2dep.c \ - tst-execstack-mod.c \ + tst-execstack-mod.c tst-dlmodcount.c \ check-textrel.c dl-sysdep.h CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables @@ -151,7 +151,7 @@ restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \ circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \ tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-align \ - $(tests-execstack-$(have-z-execstack)) + $(tests-execstack-$(have-z-execstack)) tst-dlmodcount # reldep9 test-srcs = tst-pathopt tests-vis-yes = vismain @@ -713,4 +713,8 @@ $(sort $(wildcard $(common-objpfx)*/lib*.so \ $(common-objpfx)iconvdata/*.so)) > $@ generated += check-textrel check-textrel.out + +$(objpfx)tst-dlmodcount: $(libdl) +$(objpfx)tst-dlmodcount.out: $(test-modules) + endif Index: elf/dl-close.c --- elf/dl-close.c +++ elf/dl-close.c @@ -319,6 +319,7 @@ /* Notify the debugger we are about to remove some loaded objects. */ _r_debug.r_state = RT_DELETE; _dl_debug_state (); + ++GL(dl_load_subs); #ifdef USE_TLS size_t tls_free_start; Index: elf/dl-iteratephdr.c --- elf/dl-iteratephdr.c +++ elf/dl-iteratephdr.c @@ -48,6 +48,8 @@ info.dlpi_name = l->l_name; info.dlpi_phdr = l->l_phdr; info.dlpi_phnum = l->l_phnum; + info.dlpi_adds = GL(dl_load_adds); + info.dlpi_subs = GL(dl_load_subs); ret = callback (&info, sizeof (struct dl_phdr_info), data); if (ret) break; @@ -84,6 +86,8 @@ info.dlpi_name = ""; info.dlpi_phdr = _dl_phdr; info.dlpi_phnum = _dl_phnum; + info.dlpi_adds = GL(dl_load_adds); + info.dlpi_subs = GL(dl_load_subs); ret = (*callback) (&info, sizeof (struct dl_phdr_info), data); if (ret) return ret; Index: elf/dl-object.c --- elf/dl-object.c +++ elf/dl-object.c @@ -83,6 +83,7 @@ else GL(dl_loaded) = new; ++GL(dl_nloaded); + ++GL(dl_load_adds); /* If we have no loader the new object acts as it. */ if (loader == NULL) Index: elf/dl-support.c --- elf/dl-support.c +++ elf/dl-support.c @@ -71,6 +71,11 @@ /* Number of object in the _dl_loaded list. */ unsigned int _dl_nloaded; +/* Incremented whenever something may have been added to dl_loaded. */ +unsigned long long _dl_load_adds; +/* Incremented whenever something may have been removed from dl_loaded. */ +unsigned long long _dl_load_subs; + /* Fake scope. In dynamically linked binaries this is the scope of the main application but here we don't have something like this. So create a fake scope containing nothing. */ Index: elf/link.h --- elf/link.h +++ elf/link.h @@ -100,6 +100,12 @@ const char *dlpi_name; const ElfW(Phdr) *dlpi_phdr; ElfW(Half) dlpi_phnum; + + /* Note: older versions of libc do not provide the following + members. Check the SIZE argument pass to the dl_iterate_phdr() + callback to determine whether or not they areprovided. */ + unsigned long long dlpi_adds; /* incr. when phdrs may have been added */ + unsigned long long dlpi_subs; /* incr. when phdrs may have been removed */ }; __BEGIN_DECLS Index: elf/tst-dlmodcount.c --- /dev/null +++ elf/tst-dlmodcount.c @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David Mosberger , 2004. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#define SET 0 +#define ADD 1 +#define REMOVE 2 + +#define leq(l,r) (((r) - (l)) <= ~0ULL/2) + +static int +callback (struct dl_phdr_info *info, size_t size, void *ptr) +{ + static int last_adds = 0, last_subs = 0; + intptr_t cmd = (intptr_t) ptr; + + printf (" size = %Zu\n", size); + if (size < (offsetof (struct dl_phdr_info, dlpi_subs) + + sizeof (info->dlpi_subs))) + { + fprintf (stderr, "dl_iterate_phdr failed to pass dlpi_adds/dlpi_subs\n"); + exit (5); + } + + printf (" dlpi_adds = %Lu dlpi_subs = %Lu\n", + info->dlpi_adds, info->dlpi_subs); + + switch (cmd) + { + case SET: + break; + + case ADD: + if (leq (info->dlpi_adds, last_adds)) + { + fprintf (stderr, "dlpi_adds failed to get incremented!\n"); + exit (3); + } + break; + + case REMOVE: + if (leq (info->dlpi_subs, last_subs)) + { + fprintf (stderr, "dlpi_subs failed to get incremented!\n"); + exit (4); + } + break; + } + last_adds = info->dlpi_adds; + last_subs = info->dlpi_subs; + return -1; +} + +static void * +load (const char *path) +{ + void *handle; + + printf ("loading `%s'\n", path); + handle = dlopen (path, RTLD_LAZY); + if (!handle) + exit (1); + dl_iterate_phdr (callback, (void *)(intptr_t) ADD); + return handle; +} + +static void +unload (const char *path, void *handle) +{ + int ret; + + printf ("unloading `%s'\n", path); + if (dlclose (handle) < 0) + exit (2); + dl_iterate_phdr (callback, (void *)(intptr_t) REMOVE); +} + +int +main (int argc, char **argv) +{ + void *handle1, *handle2; + + dl_iterate_phdr (callback, (void *)(intptr_t) SET); + handle1 = load ("firstobj.so"); + handle2 = load ("globalmod1.so"); + unload ("firstobj.so", handle1); + unload ("globalmod1.so", handle2); + return 0; +} Index: include/link.h --- include/link.h +++ include/link.h @@ -293,6 +293,12 @@ const char *dlpi_name; const ElfW(Phdr) *dlpi_phdr; ElfW(Half) dlpi_phnum; + + /* Note: older versions of libc do not provide the following + members. Check the SIZE argument pass to the dl_iterate_phdr() + callback to determine whether or not they areprovided. */ + unsigned long long dlpi_adds; /* incr. when phdrs may have been added */ + unsigned long long dlpi_subs; /* incr. when phdrs may have been removed */ }; extern int dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, Index: sysdeps/generic/ldsodefs.h --- sysdeps/generic/ldsodefs.h +++ sysdeps/generic/ldsodefs.h @@ -265,6 +265,11 @@ EXTERN const char *_dl_platform; EXTERN size_t _dl_platformlen; + /* Incremented whenever something may have been added to dl_loaded. */ + EXTERN unsigned long long _dl_load_adds; + /* Incremented whenever something may have been removed from dl_loaded. */ + EXTERN unsigned long long _dl_load_subs; + #ifndef MAP_ANON /* File descriptor referring to the zero-fill device. */ EXTERN int _dl_zerofd; From aj@suse.de Sat Jan 24 08:46:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sat, 24 Jan 2004 08:46:00 -0000 Subject: Import obstack.* from gnulib Message-ID: I've imported the current obstack versions into glibc. The changes should not effect the code but compilation: - K&R support removed - casts as lvalues removed Ok to commit? I'm appending the patch for reference, Andreas 2004-01-24 Andreas Jaeger * malloc/obstack.h: Import gnulib version. * malloc/obstack.c: Likewise. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: libc-diff URL: -------------- next part -------------- -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From drepper@redhat.com Sat Jan 24 20:27:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 24 Jan 2004 20:27:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: <16402.2189.718828.875017@napali.hpl.hp.com> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> <16399.6885.708290.614809@napali.hpl.hp.com> <20040122062944.GC6811@sunsite.ms.mff.cuni.cz> <16402.2189.718828.875017@napali.hpl.hp.com> Message-ID: <4012D162.1000502@redhat.com> David Mosberger wrote: > Attached is an updated patch. "make check subdirs=elf" passes all > tests (including the new tst-dlmodcount test). I've applied the patch. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From roland@redhat.com Sat Jan 24 20:53:00 2004 From: roland@redhat.com (Roland McGrath) Date: Sat, 24 Jan 2004 20:53:00 -0000 Subject: Import obstack.* from gnulib In-Reply-To: Andreas Jaeger's message of Saturday, 24 January 2004 09:46:53 +0100 Message-ID: <200401242053.i0OKrlQD018183@magilla.sf.frob.com> > > I've imported the current obstack versions into glibc. The changes > should not effect the code but compilation: > - K&R support removed > - casts as lvalues removed > > Ok to commit? Looks fine to me. Thanks, Roland From drepper@redhat.com Sat Jan 24 21:34:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 24 Jan 2004 21:34:00 -0000 Subject: Import obstack.* from gnulib In-Reply-To: References: Message-ID: <4012E4BB.9070807@redhat.com> Andreas Jaeger wrote: > @@ -119,40 +119,22 @@ extern "C" { > #endif > > #ifndef __INT_TO_PTR > -#if defined __STDC__ && __STDC__ > -# define __INT_TO_PTR(P) ((void *) ((P) + (char *) 0)) > -#else > # define __INT_TO_PTR(P) ((P) + (char *) 0) > #endif > -#endif Why should the K&R branch survive here? Maybe there are other places like this. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From aj@suse.de Sun Jan 25 06:33:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 25 Jan 2004 06:33:00 -0000 Subject: Import obstack.* from gnulib In-Reply-To: <4012E4BB.9070807@redhat.com> (Ulrich Drepper's message of "Sat, 24 Jan 2004 13:33:47 -0800") References: <4012E4BB.9070807@redhat.com> Message-ID: Ulrich Drepper writes: > Andreas Jaeger wrote: > >> @@ -119,40 +119,22 @@ extern "C" { >> #endif >> >> #ifndef __INT_TO_PTR >> -#if defined __STDC__ && __STDC__ >> -# define __INT_TO_PTR(P) ((void *) ((P) + (char *) 0)) >> -#else >> # define __INT_TO_PTR(P) ((P) + (char *) 0) >> #endif >> -#endif > > Why should the K&R branch survive here? Maybe there are other places > like this. Let's ask the gnulib folks about this. I suggest to import this now - and handle those changes later. Ok? Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From drepper@redhat.com Sun Jan 25 08:27:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 25 Jan 2004 08:27:00 -0000 Subject: Import obstack.* from gnulib In-Reply-To: References: <4012E4BB.9070807@redhat.com> Message-ID: <40137DCB.7010309@redhat.com> Andreas Jaeger wrote: > I suggest to import this now - and handle those changes later. Ok? No, why? We don't add incomplete changes since this only means it gets forgotten. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From aj@suse.de Sun Jan 25 09:02:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Sun, 25 Jan 2004 09:02:00 -0000 Subject: Import obstack.* from gnulib In-Reply-To: <40137DCB.7010309@redhat.com> (Ulrich Drepper's message of "Sun, 25 Jan 2004 00:26:51 -0800") References: <4012E4BB.9070807@redhat.com> <40137DCB.7010309@redhat.com> Message-ID: Ulrich Drepper writes: > Andreas Jaeger wrote: > >> I suggest to import this now - and handle those changes later. Ok? > > No, why? We don't add incomplete changes since this only means it gets > forgotten. It removes the casts as lvalues to make GCC 3.5 happy - and merging it now and working from there to get the other changes would make it easier. But the change you mentioned is according to the ChangeLog of gnulib needed for C++ compilation, the (void *) breaks it. Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From davidm@napali.hpl.hp.com Mon Jan 26 21:48:00 2004 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Mon, 26 Jan 2004 21:48:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: <4012D162.1000502@redhat.com> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> <16399.6885.708290.614809@napali.hpl.hp.com> <20040122062944.GC6811@sunsite.ms.mff.cuni.cz> <16402.2189.718828.875017@napali.hpl.hp.com> <4012D162.1000502@redhat.com> Message-ID: <16405.35582.830546.716126@napali.hpl.hp.com> >>>>> On Sat, 24 Jan 2004 12:11:14 -0800, Ulrich Drepper said: Uli> David Mosberger wrote: >> Attached is an updated patch. "make check subdirs=elf" passes >> all tests (including the new tst-dlmodcount test). Uli> I've applied the patch. Thanks! In the meantime, it occurred to me that we can get rid of one of the "unsigned long long" variables by taking advantage of the fact that "_dl_nloaded == _dl_load_adds - _dl_load_subs" (provided there are never more than 0xffffffff shared objects loaded). Apart from saving 8 bytes of global data, it also has the advantage that it makes code maintenance a bit easier. The rule is very simple now: wherever _dl_nloaded gets incremented, _dl_load_adds needs to be incremented as well. If it looks OK to you, please apply (it was "make subdirs=elf check" tested). Thanks, --david ChangeLog 2004-01-26 David Mosberger * elf/link.h (struct dl_phdr_info): Fix typo in comment. * elf/rtld.c (dl_main): After incrementing dl_nloaded, also increment dl_load_adds. * elf/dl-iteratephdr.c (__dl_iterate_phdr): Replace GL(dl_load_subs) with equivalent GL(dl_load_adds - GL(dl_nloaded). (dl_iterate_phdr): Likewise. * elf/dl-close.c (_dl_close): Delete increment of GL(dl_load_subs). * elf/dl-support.c: Remove global variable _dl_load_subs. * sysdeps/generic/ldsodefs.h (struct rtld_global): Remove _dl_load_subs member. Index: elf/dl-close.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-close.c,v retrieving revision 1.99 diff -u -r1.99 dl-close.c --- elf/dl-close.c 24 Jan 2004 20:07:38 -0000 1.99 +++ elf/dl-close.c 26 Jan 2004 21:42:35 -0000 @@ -319,7 +319,6 @@ /* Notify the debugger we are about to remove some loaded objects. */ _r_debug.r_state = RT_DELETE; _dl_debug_state (); - ++GL(dl_load_subs); #ifdef USE_TLS size_t tls_free_start; Index: elf/dl-iteratephdr.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-iteratephdr.c,v retrieving revision 1.10 diff -u -r1.10 dl-iteratephdr.c --- elf/dl-iteratephdr.c 24 Jan 2004 20:07:51 -0000 1.10 +++ elf/dl-iteratephdr.c 26 Jan 2004 21:42:35 -0000 @@ -49,7 +49,7 @@ info.dlpi_phdr = l->l_phdr; info.dlpi_phnum = l->l_phnum; info.dlpi_adds = GL(dl_load_adds); - info.dlpi_subs = GL(dl_load_subs); + info.dlpi_subs = GL(dl_load_adds) - GL(dl_nloaded); ret = callback (&info, sizeof (struct dl_phdr_info), data); if (ret) break; @@ -87,7 +87,7 @@ info.dlpi_phdr = _dl_phdr; info.dlpi_phnum = _dl_phnum; info.dlpi_adds = GL(dl_load_adds); - info.dlpi_subs = GL(dl_load_subs); + info.dlpi_subs = GL(dl_load_adds) - GL(dl_nloaded); ret = (*callback) (&info, sizeof (struct dl_phdr_info), data); if (ret) return ret; Index: elf/dl-support.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-support.c,v retrieving revision 1.80 diff -u -r1.80 dl-support.c --- elf/dl-support.c 24 Jan 2004 20:08:29 -0000 1.80 +++ elf/dl-support.c 26 Jan 2004 21:42:35 -0000 @@ -73,8 +73,6 @@ /* Incremented whenever something may have been added to dl_loaded. */ unsigned long long _dl_load_adds; -/* Incremented whenever something may have been removed from dl_loaded. */ -unsigned long long _dl_load_subs; /* Fake scope. In dynamically linked binaries this is the scope of the main application but here we don't have something like this. So Index: elf/link.h =================================================================== RCS file: /cvs/glibc/libc/elf/link.h,v retrieving revision 1.77 diff -u -r1.77 link.h --- elf/link.h 24 Jan 2004 20:08:50 -0000 1.77 +++ elf/link.h 26 Jan 2004 21:42:35 -0000 @@ -103,7 +103,7 @@ /* Note: the next two members were introduced after the first version of this structure was available. Check the SIZE - argument pass to the dl_iterate_phdr() callback to determine + argument passed to the dl_iterate_phdr() callback to determine whether or not they are provided. */ /* Incremented when a new object may have been added. */ Index: elf/rtld.c =================================================================== RCS file: /cvs/glibc/libc/elf/rtld.c,v retrieving revision 1.310 diff -u -r1.310 rtld.c --- elf/rtld.c 24 Jan 2004 08:33:44 -0000 1.310 +++ elf/rtld.c 26 Jan 2004 21:42:35 -0000 @@ -1020,6 +1020,7 @@ GL(dl_loaded)->l_next = &GL(dl_rtld_map); GL(dl_rtld_map).l_prev = GL(dl_loaded); ++GL(dl_nloaded); + ++GL(dl_load_adds); /* If LD_USE_LOAD_BIAS env variable has not been seen, default to not using bias for non-prelinked PIEs and libraries Index: sysdeps/generic/ldsodefs.h =================================================================== RCS file: /cvs/glibc/libc/sysdeps/generic/ldsodefs.h,v retrieving revision 1.89 diff -u -r1.89 ldsodefs.h --- sysdeps/generic/ldsodefs.h 24 Jan 2004 20:10:18 -0000 1.89 +++ sysdeps/generic/ldsodefs.h 26 Jan 2004 21:42:36 -0000 @@ -267,8 +267,6 @@ /* Incremented whenever something may have been added to dl_loaded. */ EXTERN unsigned long long _dl_load_adds; - /* Incremented whenever something may have been removed from dl_loaded. */ - EXTERN unsigned long long _dl_load_subs; #ifndef MAP_ANON /* File descriptor referring to the zero-fill device. */ From drepper@redhat.com Mon Jan 26 22:39:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 26 Jan 2004 22:39:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: <16405.35582.830546.716126@napali.hpl.hp.com> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> <16399.6885.708290.614809@napali.hpl.hp.com> <20040122062944.GC6811@sunsite.ms.mff.cuni.cz> <16402.2189.718828.875017@napali.hpl.hp.com> <4012D162.1000502@redhat.com> <16405.35582.830546.716126@napali.hpl.hp.com> Message-ID: <401593FF.6080802@redhat.com> David Mosberger wrote: > In the meantime, it occurred to me that we can get rid of one of the > "unsigned long long" variables by taking advantage of the fact that > "_dl_nloaded == _dl_load_adds - _dl_load_subs" _dl_nloaded is not available outside ld.so. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From roland@redhat.com Mon Jan 26 22:58:00 2004 From: roland@redhat.com (Roland McGrath) Date: Mon, 26 Jan 2004 22:58:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: Ulrich Drepper's message of Monday, 26 January 2004 14:26:07 -0800 <401593FF.6080802@redhat.com> Message-ID: <200401262258.i0QMw176008891@magilla.sf.frob.com> > David Mosberger wrote: > > > In the meantime, it occurred to me that we can get rid of one of the > > "unsigned long long" variables by taking advantage of the fact that > > "_dl_nloaded == _dl_load_adds - _dl_load_subs" > > _dl_nloaded is not available outside ld.so. It's part of rtld_global, just like _dl_load_adds is. We are only talking about dl_iterate_phdr's implementation here. From davidm@napali.hpl.hp.com Mon Jan 26 23:03:00 2004 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Mon, 26 Jan 2004 23:03:00 -0000 Subject: enabling caching for dl_iterate_phdr() In-Reply-To: <401593FF.6080802@redhat.com> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> <16399.6885.708290.614809@napali.hpl.hp.com> <20040122062944.GC6811@sunsite.ms.mff.cuni.cz> <16402.2189.718828.875017@napali.hpl.hp.com> <4012D162.1000502@redhat.com> <16405.35582.830546.716126@napali.hpl.hp.com> <401593FF.6080802@redhat.com> Message-ID: <16405.40092.813668.884013@napali.hpl.hp.com> >>>>> On Mon, 26 Jan 2004 14:26:07 -0800, Ulrich Drepper said: Uli> David Mosberger wrote: >> In the meantime, it occurred to me that we can get rid of one of >> the "unsigned long long" variables by taking advantage of the >> fact that "_dl_nloaded == _dl_load_adds - _dl_load_subs" Uli> _dl_nloaded is not available outside ld.so. I'm probably missing something obvious, but why is this a problem? As far as I can see, _dl_nloaded has the same visibility as _dl_load_subs. --david From aj@suse.de Tue Jan 27 14:43:00 2004 From: aj@suse.de (Andreas Jaeger) Date: Tue, 27 Jan 2004 14:43:00 -0000 Subject: Import obstack.* from gnulib In-Reply-To: <40137DCB.7010309@redhat.com> (Ulrich Drepper's message of "Sun, 25 Jan 2004 00:26:51 -0800") References: <4012E4BB.9070807@redhat.com> <40137DCB.7010309@redhat.com> Message-ID: Paul Eggert wrote the following: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > From: Ulrich Drepper > Date: Sat, 24 Jan 2004 13:33:47 -0800 > > > @@ -119,40 +119,22 @@ extern "C" { > > #endif > > > > #ifndef __INT_TO_PTR > > -#if defined __STDC__ && __STDC__ > > -# define __INT_TO_PTR(P) ((void *) ((P) + (char *) 0)) > > -#else > > # define __INT_TO_PTR(P) ((P) + (char *) 0) > > #endif > > -#endif > > Why should the K&R branch survive here? Because the "ANSI branch" was incorrect for C++ compilation. This problem was originally described by Alexandre Duret-Lutz in . The above-quoted hunk isn't complete by itself. It's paired with the following change to obstack_finish: - __INT_TO_PTR ((h)->temp)) + (void *) __INT_TO_PTR ((h)->temp)) and this pair of hunks causes the resulting code to conform to C89 (as well as to C99; and to K&R C also, not that it matters). > Maybe there are other places like this. No. I didn't find any other places when I looked for them. This was in July when I installed this patch into gnulib . Also, the patch worked for Alexandre, which is a test that the changes are complete. > From: Ulrich Drepper > Date: Sun, 25 Jan 2004 00:26:51 -0800 > > Andreas Jaeger wrote: > > I suggest to import this now - and handle those changes later. Ok? > > No, why? We don't add incomplete changes since this only means it gets > forgotten. Andreas, I assume that by "those changes later" you mean some other set of changes for the "other places like this". If I understand you correctly, there are no "those changes". Your email contained only one set of changes, which are complete. There is no K&R code in the resulting file. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So, can I commit the current version now? Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Tue Jan 27 18:59:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 27 Jan 2004 18:59:00 -0000 Subject: [PATCH] One more RELRO fix Message-ID: <20040127165137.GU6811@sunsite.ms.mff.cuni.cz> Hi! On !DONT_USE_BOOTSTRAP_MAP platforms, prelink stopped working. The problem is that ehdr = (ElfW(Ehdr) *) bootstrap_map.l_addr; of course doesn't work with prelinked ld.so. Setting GL(dl_rtld_map).l_relro_{addr,size} can very well be done later, after ld.so itself has been relocated for the first time but before second time relocation and it should be even faster (_dl_start used to cycle through all program headers, while the code in patch as PT_GNU_RELRO check is the sole thing in the loop can go from the last Phdr down till it finds it (ATM it is always the last one)). Also, ld.so apparently did not handle PT_GNU_RELRO program header in the executable, which this patch adds as well. Although in most executables PT_GNU_RELRO would be really small (essentially small .got, .dynamic, .ctors/.dtors/.jcr and that's about it), there are cases where it can be bigger and IMHO ld.so should handle it. 2004-01-27 Jakub Jelinek * elf/rtld.c (_dl_start_final): Don't set l_relro_* here. (_dl_start): And neither here. (dl_main): Set GL(dl_loaded)->l_relro_* and GL(dl_rtld_map)->l_relro_*. --- libc/elf/rtld.c.jj 2004-01-27 15:17:27.000000000 +0100 +++ libc/elf/rtld.c 2004-01-27 15:33:34.043449517 +0100 @@ -224,8 +224,6 @@ _dl_start_final (void *arg, struct dl_st memcpy (GL(dl_rtld_map).l_info, info->l.l_info, sizeof GL(dl_rtld_map).l_info); GL(dl_rtld_map).l_mach = info->l.l_mach; - GL(dl_rtld_map).l_relro_addr = info->l.l_relro_addr; - GL(dl_rtld_map).l_relro_size = info->l.l_relro_size; #endif _dl_setup_hash (&GL(dl_rtld_map)); GL(dl_rtld_map).l_opencount = 1; @@ -351,17 +349,16 @@ _dl_start (void *arg) on the `l_addr' value, which is not the value we want when prelinked. */ #if USE___THREAD dtv_t initdtv[3]; -#endif /* USE___THREAD */ ElfW(Ehdr) *ehdr # ifdef DONT_USE_BOOTSTRAP_MAP = (ElfW(Ehdr) *) &_begin; # else +# error This will not work with prelink. = (ElfW(Ehdr) *) bootstrap_map.l_addr; # endif ElfW(Phdr) *phdr = (ElfW(Phdr) *) ((void *) ehdr + ehdr->e_phoff); size_t cnt = ehdr->e_phnum; /* PT_TLS is usually the last phdr. */ while (cnt-- > 0) -#if USE___THREAD if (phdr[cnt].p_type == PT_TLS) { void *tlsblock; @@ -457,13 +454,7 @@ _dl_start (void *arg) /* So far this is module number one. */ bootstrap_map.l_tls_modid = 1; } - else #endif /* USE___THREAD */ - if (phdr[cnt].p_type == PT_GNU_RELRO) - { - bootstrap_map.l_relro_addr = phdr[cnt].p_vaddr; - bootstrap_map.l_relro_size = phdr[cnt].p_memsz; - } #ifdef ELF_MACHINE_BEFORE_RTLD_RELOC ELF_MACHINE_BEFORE_RTLD_RELOC (bootstrap_map.l_info); @@ -958,6 +949,11 @@ of this helper program; chances are you case PT_GNU_STACK: GL(dl_stack_flags) = ph->p_flags; break; + + case PT_GNU_RELRO: + GL(dl_loaded)->l_relro_addr = ph->p_vaddr; + GL(dl_loaded)->l_relro_size = ph->p_memsz; + break; } #ifdef USE_TLS /* Adjust the address of the TLS initialization image in case @@ -1030,10 +1026,21 @@ of this helper program; chances are you /* Set up the program header information for the dynamic linker itself. It is needed in the dl_iterate_phdr() callbacks. */ ElfW(Ehdr) *rtld_ehdr = (ElfW(Ehdr) *) GL(dl_rtld_map).l_map_start; - GL(dl_rtld_map).l_phdr = (ElfW(Phdr) *) (GL(dl_rtld_map).l_map_start - + rtld_ehdr->e_phoff); + ElfW(Phdr) *rtld_phdr = (ElfW(Phdr) *) (GL(dl_rtld_map).l_map_start + + rtld_ehdr->e_phoff); + GL(dl_rtld_map).l_phdr = rtld_phdr; GL(dl_rtld_map).l_phnum = rtld_ehdr->e_phnum; + /* PT_GNU_RELRO is usually the last phdr. */ + size_t cnt = rtld_ehdr->e_phnum; + while (cnt-- > 0) + if (rtld_phdr[cnt].p_type == PT_GNU_RELRO) + { + GL(dl_rtld_map).l_relro_addr = rtld_phdr[cnt].p_vaddr; + GL(dl_rtld_map).l_relro_size = rtld_phdr[cnt].p_memsz; + break; + } + /* We have two ways to specify objects to preload: via environment variable and via the file /etc/ld.so.preload. The latter can also be used when security is enabled. */ Jakub From drepper@redhat.com Wed Jan 28 03:53:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 28 Jan 2004 03:53:00 -0000 Subject: Import obstack.* from gnulib In-Reply-To: References: Message-ID: <40173225.3080803@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Jaeger wrote: > * malloc/obstack.h: Import gnulib version. > * malloc/obstack.c: Likewise. I've checked in the patch with one additional change. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAFzIl2ijCOnn/RHQRApqoAKC1MooPnZ9MHErg06ZzQzRLV1V4+gCfT89o WLzR5OLy7HZzv7S/FbChShM= =BFx3 -----END PGP SIGNATURE----- From schwab@suse.de Fri Jan 30 13:02:00 2004 From: schwab@suse.de (Andreas Schwab) Date: Fri, 30 Jan 2004 13:02:00 -0000 Subject: ia64/bits/siginfo.h Message-ID: __ILL_BREAK etc. don't exist, only the non-prefixed names. Andreas. 2004-01-30 Andreas Schwab * sysdeps/unix/sysv/linux/ia64/bits/siginfo.h (ILL_BREAK) (FPE_DECOVF, FPE_DECDIV, FPE_DECERR, FPE_INVASC, FPE_INVDEC) (SEGV_PSTKOVF): Remove underscore prefix from definition. --- sysdeps/unix/sysv/linux/ia64/bits/siginfo.h.~1.13.~ 2003-04-22 10:02:04.000000000 +0200 +++ sysdeps/unix/sysv/linux/ia64/bits/siginfo.h 2004-01-30 13:53:15.175002840 +0100 @@ -1,5 +1,5 @@ /* siginfo_t, sigevent and constants. Linux/ia64 version. - Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by David Mosberger-Tang . @@ -176,7 +176,7 @@ enum # ifdef __USE_GNU , ILL_BREAK -# define ILL_BREAK __ILL_BREAK +# define ILL_BREAK ILL_BREAK # endif }; @@ -201,15 +201,15 @@ enum # define FPE_FLTSUB FPE_FLTSUB # ifdef __USE_GNU , FPE_DECOVF -# define FPE_DECOVF __FPE_DECOVF +# define FPE_DECOVF FPE_DECOVF , FPE_DECDIV -# define FPE_DECDIV __FPE_DECDIV +# define FPE_DECDIV FPE_DECDIV , FPE_DECERR -# define FPE_DECERR __FPE_DECERR +# define FPE_DECERR FPE_DECERR , FPE_INVASC -# define FPE_INVASC __FPE_INVASC +# define FPE_INVASC FPE_INVASC , FPE_INVDEC -# define FPE_INVDEC __FPE_INVDEC +# define FPE_INVDEC FPE_INVDEC # endif }; @@ -222,7 +222,7 @@ enum # define SEGV_ACCERR SEGV_ACCERR # ifdef __USE_GNU , SEGV_PSTKOVF /* Paragraph stack overflow. */ -# define SEGV_PSTKOVF __SEGV_PSTKOVF +# define SEGV_PSTKOVF SEGV_PSTKOVF # endif }; -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Maxfeldstra??e 5, 90409 N??rnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From drepper@redhat.com Fri Jan 30 20:43:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 30 Jan 2004 20:43:00 -0000 Subject: ia64/bits/siginfo.h In-Reply-To: References: Message-ID: <401AC1DB.8040500@redhat.com> Andreas Schwab wrote: > __ILL_BREAK etc. don't exist, only the non-prefixed names. I've applied the patch. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ???